Last updated
Last updated
The Interface Class abstracts the encoding and decoding required to interact with contracts on the Hedera Hashgraph.
Many of the standards organically evolved along side the language, which other languages have adopted to remain compatible with existing deployed contracts.
The EVM itself does not understand what the ABI is. It is simply an agreed upon set of formats to encode various types of data which each contract can expect so they can interoperate with each other.
new hethers.utils.Interface( abi )
Create a new Interface from a JSON string or object representing abi.
The abi may be a JSON string or the parsed Object (using JSON.parse) which is emitted by the (or compatible languages).
The abi may also be a .
All the Fragments in the interface.
All the Error Fragments in the interface.
All the Event Fragments in the interface.
All the Function Fragments in the interface
The Constructor Fragments for the interface.
interface.format( [ format ] ) ⇒ string | Array<string>
Return the formatted Interface. If the format type is json
a single string is returned, otherwise an Array of the human-readable strings is returned.
Return the encoded deployment data, which can be concatenated to the deployment bytecode of a contract to pass values into the contract constructor.
Most developers will not need this method, but may be useful for authors of a mock hashgraph.
interface.encodeFilterTopics( fragment, values ) ⇒ Array<topic | Array<topic>>
Returns the encoded data, which can be used as the data for a transaction for fragment (see Specifying Fragments) for the given values.
Most developers will not need this method, but may be useful for authors of a mock hashgraph.
Most developers won't need this, as the decodeFunctionResult
will automatically decode errors if the data represents a revert.
If topics is not specified, placeholders will be inserted into the result.
Most developers will not need this method, but may be useful for debugging or inspecting transactions.
The functions are generally the most useful for most developers. They will automatically search the ABI for a matching Event or Function and decode the components as a fully specified descriptio
Search for the error that matches the error selector in data and parse out the details.
Search the event that matches the log topic hash and parse the values the log represents.
Search for the function that matches the transaction data sighash and parse the transaction properties.
A Result is an array, so each value can be accessed as a positional argument.
Additionally, if values are named, the identical object as its positional value can be accessed by its name.
The name length
is however reserved as it is part of the Array, so any named value for this key is renamed to _length
. If there is a name collision, only the first is available by its key.
The values of the input parameters of the error.
errorDescription.name ⇒ string
The error name. (e.g. AccountLocked
)
errorDescription.signature ⇒ string
The error signature. (e.g. AccountLocked(address,uint256)
)
errorDescription.sighash ⇒ string
The selector of the error.
The values of the input parameters of the event.
logDescription.name ⇒ string
The event name. (e.g. Transfer
)
logDescription.signature ⇒ string
The event signature. (e.g. Transfer(address,address,uint256)
)
logDescription.topic ⇒ string
The topic hash.
The decoded values from the transaction data which were passed as the input parameters.
transactionDescription.name ⇒ string
The name of the function. (e.g. transfer
)
transactionDescription.sighash ⇒ string
The sighash (or function selector) that matched the transaction data.
transactionDescription.signature ⇒ string
The signature of the function. (e.g. transfer(address,uint256)
)
The value from the transaction.
When specifying a fragment to any of the functions in an Interface, any of the following may be used:
The name of the event or function, if it is unique and non-ambiguous within the ABI (e.g. transfer
)
The signature of the event or function. The signature is normalized, so, for example, uint
and uint256
are equivalent (e.g. transfer(address, uint)
)
The sighash or topichash of the function. The sighash is often referred to the function selector in Solidity (e.g. 0xa9059cbb
)
Returns the for fragment (see ).
Returns the for fragment (see ).
Returns the for fragment (see ).
Return the sighash (or Function Selector) for fragment (see ).
Return the topic hash for fragment (see ).
Returns the encoded error result, which would normally be the response from a reverted call for fragment (see ) for the given values.
Returns the encoded topic filter, which can be passed to getLogs for fragment (see ) for the given values.
Each topic is a 32 byte (64 nibble) .
Returns the encoded result, which would normally be the response from a call for fragment (see ) for the given values.
Returns the decoded values from the result of a call during a revert for fragment (see ) for the given data.
Returns the decoded event values from an event log for fragment (see ) for the given data with the optional topics.
Most developers will find the more convenient for decoding event data, as they will automatically detect the matching event.
Returns the decoded values from transaction data for fragment (see ) for the given data.
Most developers will also find the more convenient for decoding transaction data, as they will automatically detect the matching function.
Returns the decoded values from the result of a call for fragment (see ) for the given data.
The which matches the selector in the data.
The which matches the topic in the Log.
The which matches the sighash in the transaction data.
A