json interface
The json interface is a json object describing the Application Binary Interface (ABI) for a smart contract. Using this json interface, web3.js is able to create JavaScript object representing the smart contract and its methods and events using the web3.eth.Contract object.
Specification
Functions:
type:"function","constructor"(can be omitted, defaulting to"function";"fallback"also possible but not relevant in web3.js).name: the name of the function (only present for function types).constant:trueif function is specified to not modify the blockchain state.payable:trueif function accepts ether, defaults tofalsestateMutability: a string with one of the following values:pure(specified to not read blockchain state)view(same asconstantabove)nonpayableandpayable(same aspayableabove)
inputs: an array of objects, each of which contains:name: the name of the parametertype: the canonical type of the parameter
outputs: an array of objects same asinputs, can be omitted if no outputs exist.
Events:
type: always"event"name: the name of the event.inputs: an array of objects, each of which contains:name: the name of the parameter.type: the canonical type of the parameter.indexed:trueif the field is part of the log's topics,falseif it one of the log's data segment.
anonymous:trueif the event was declared asanonymous.
Example:
Last updated
Was this helpful?