The :ref:`json interface <glossary-json-interface>` object derived from the `ABI <https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI>`_ of this contract.
``Array`` - jsonInterface: The :ref:`json interface <glossary-json-interface>` for this contract. Re-setting this will regenerate the methods and events of the contract instance.
Creates a transaction object for that method, which then can be :ref:`called <contract-call>`, :ref:`send <contract-send>`, :ref:`estimated <contract-estimateGas>`or :ref:`ABI encoded <contract-encodeABI>`.
The methods of this smart contract are available through:
- The name: ``myContract.methods.myMethod(123)``
- The name with parameters: ``myContract.methods['myMethod(uint256)'](123)``
- The signature: ``myContract.methods['0x58cf5f10'](123)``
This allows calling functions with same name but different parameters from the JavaScript contract object.
----------
Parameters
----------
Parameters of any method depend on the smart contracts methods, defined in the :ref:`JSON interface <glossary-json-interface>`.
-------
Returns
-------
``Object``: The transaction object:
-``Array`` - arguments: The arguments passed to the method before. They can be changed.
-``Function`` - :ref:`call <contract-call>`: Will call the "constant" method and execute its smart contract method in the EVM without sending a transaction (Can't alter the smart contract state).
-``Function`` - :ref:`send <contract-send>`: Will send a transaction to the smart contract and execute its method (Can alter the smart contract state).
-``Function`` - :ref:`estimateGas <contract-estimateGas>`: Will estimate the gas used when the method would be executed on chain.
-``Function`` - :ref:`encodeABI <contract-encodeABI>`: Encodes the ABI for this method. This can be send using a transaction, call the method or passing into another smart contracts method as argument.
Will call a "constant" method and execute its smart contract method in the EVM without sending any transaction. Note calling can not alter the smart contract state.
----------
Parameters
----------
1.``Object`` - **options** (optional): The options used for calling.
*``String`` - **from** (optional): The address the call "transaction" should be made from.
*``String`` - **gasPrice** (optional): The gas price in wei to use for this call "transaction".
*``Number`` - **gas** (optional): The maximum gas provided for this call "transaction" (gas limit).
2.``Function`` - **callback** (optional): This callback will be fired with the result of the smart contract method execution as the second argument, or with an error object as the first argument.
-------
Returns
-------
``Promise`` returns ``Mixed``: The return value(s) of the smart contract method.
// TODO add specific examples, once the decoder is extended
``PromiEvent``: A promise combined event emitter. Will be resolved when the transaction *receipt* is available. Additionally the following events are available:
-``"transactionHash"`` returns ``String``: is fired right after the transaction is send and a transaction hash is available.
-``"confirmation"`` returns ``Number``, ``Object``: is fired for every confirmation up to the 12th confirmation. Receives the confirmation number as the first and the receipt as the second argument. Fired from confirmation 0 on, which is the block where its minded.
Will call estimate the gas a method execution will take when executed in the EVM without.
The estimation can differ from the actual gas used when later sending a transaction, as the state of the smart contract can be different at that time.
----------
Parameters
----------
1.``Object`` - **options** (optional): The options used for calling.
*``String`` - **from** (optional): The address the call "transaction" should be made from.
*``Number`` - **gas** (optional): The maximum gas provided for this call "transaction" (gas limit). Setting a specific value helps to detect out of gas errors. If all gas is used it will return the same number.
2.``Function`` - **callback** (optional): This callback will be fired with the result of the gas estimation as the second argument, or with an error object as the first argument.
-------
Returns
-------
``Promise`` returns ``Number``: The gas amount estimated.
1.``String`` - **event**: The name of the event in the contract, or ``"allEvents"`` to get all events.
2.``Object`` - **options** (optional): The options used for deployment.
*``Object`` - **filter** (optional): Let you filter events by indexed parameters, e.g. ``{filter: {myNumber: [12,13]}}`` means all events where "myNumber" is 12 or 13.
*``Number`` - **fromBlock** (optional): The block number from which to get events on.
*``Number`` - **toBlock** (optional): The block number until events to get (Defaults to ``"latest"``).
*``Array`` - **topics** (optional): This allows to manually set the topics for the event filter. If given the filter property and event signature (topic[0]) will not be set automatically.
3.``Function`` - **callback** (optional): This callback will be fired with an array of event logs as the second argument, or an error as the first argument.
.._contract-getPastEvents-return:
-------
Returns
-------
``Promise`` returns ``Array``: An array with the past event ``Objects``, matching the given event name and filter.
The structure of the returned event ``Object`` in the ``Arrray`` looks as follows:
-``Object`` - **returnValues**: The return values coming from the event, e.g. ``{myVar: 1, myVar2: '0x234...'}``.
-``String`` - **event**: The event name.
-``Number`` - **logIndex**: Integer of the event index position in the block.
-``Number`` - **transactionIndex**: Integer of the transaction's index position, the event was created in.
-``String`` 32 Bytes - **transactionHash**: Hash of the transaction this event was created in.
-``String`` 32 Bytes - **blockHash**: Hash of the block where this event was created in. ``null`` when its still pending.
-``Number`` - **blockNumber**: The block number where this log was created in. ``null`` when still pending.
-``String`` - **address**: from which this event originated from.
-------
Example
-------
..code-block:: javascript
myContract.getPastEvents('MyEvent', {
filter: {myIndexedParam: [20,23], myOtherIndexedParam: '0x123456789...'}, // Using an array means OR: e.g. 20 or 23
1.``String`` - **event**: The name of the event in the contract, or ``"allEvents"`` to get all events.
2.``Object`` - **options** (optional): The options used for deployment.
*``Object`` - **filter** (optional): Let you filter events by indexed parameters, e.g. ``{filter: {myNumber: [12,13]}}`` means all events where "myNumber" is 12 or 13.
*``Array`` - **topics** (optional): This allows to manually set the topics for the event filter. If given the filter property and event signature (topic[0]) will not be set automatically.
1.``Object`` - **options** (optional): The options used for deployment.
*``Object`` - **filter** (optional): Let you filter events by indexed parameters, e.g. ``{filter: {myNumber: [12,13]}}`` means all events where "myNumber" is 12 or 13.
*``Number`` - **fromBlock** (optional): The block number from which to get events on.
*``Array`` - **topics** (optional): This allows to manually set the topics for the event filter. If given the filter property and event signature (topic[0]) will not be set automatically.
2.``Function`` - **callback** (optional): This callback will be fired for each event as the second argument, or an error as the first argument.
-------
Returns
-------
``EventEmitter``: The event emitter has the following events:
-``"data"`` returns ``Object``: Fires on each incoming event with the event object as argument.
-``"changed"`` returns ``Object``: Fires on each event which was removed from the blockchain. The event will have the additional property ``"removed: true"``.
-``"error"`` returns ``Object``: Fires when an error in the subscription occours.
For the structure of a returned event ``Object`` see :ref:`getPastEvents return values <contract-getPastEvents-return>`.
-------
Example
-------
..code-block:: javascript
myContract.events.MyEvent({
filter: {myIndexedParam: [20,23], myOtherIndexedParam: '0x123456789...'}, // Using an array means OR: e.g. 20 or 23
fromBlock: 0
}, function(error, event){ console.log(event); })
.on('data', function(event){
console.log(event); // same results as the optional callback above