The Application Binary Interface (ABI) describes how method input parameters should be encoded, their results decoded, and how to decode events and errors.
See About ABIs for more details how they are used.
Returns all errors found in a Result.
Since certain errors encountered when creating a Result do not impact the ability to continue parsing data, they are deferred until they are actually accessed. Hence a faulty string in an Event that is never used does not impact the program flow.
However, sometimes it may be useful to access, identify or validate correctness of a Result.
A Result is a sub-class of Array, which allows accessing any of its values either positionally by its index or, if keys are provided by its name.
Creates a new Result for items with each entry also accessible by its corresponding name in keys.
Since it is possible to have a key whose name conflicts with a method on a Result or its superclass Array, or any JavaScript keyword, this ensures all named values are still accessible by name.
The Interface class is a low-level class that accepts an ABI and provides all the necessary functionality to encode and decode paramaters to and results from methods, events and errors.
It also provides several convenience methods to automatically search and find matching transactions and events to parse them.
An InterfaceAbi may be any supported ABI format.
A string is expected to be a JSON string, which will be parsed using JSON.parse. This means that the value must be a valid JSON string, with no stray commas, etc.
An array may contain any combination of:
- Human-Readable fragments
- Parsed JSON fragment
- Fragment instances
A Human-Readable Fragment is a string which resembles a Solidity signature and is introduced in this blog entry. For example, function balanceOf(address) view returns (uint).
A Parsed JSON Fragment is a JavaScript Object desribed in the Solidity documentation.
When using the interface.parseError to automatically match an error for a call result for parsing, an ErrorDescription is returned.
An Interface abstracts many of the low-level details for encoding and decoding the data on the blockchain.
An ABI provides information on how to encode data to send to a Contract, how to decode the results and events and how to interpret revert errors.
The ABI can be specified by any supported format.
Decodes the result data (e.g. from an eth_call) for the specified error (see getError for valid values for key).
Most developers should prefer the parseCallResult method instead, which will automatically detect a CALL_EXCEPTION and throw the corresponding error.
Decodes the data from a transaction tx.data for the function specified (see getFunction for valid values for fragment).
Most developers should prefer the parseTransaction method instead, which will automatically detect the fragment.
Decodes the result data (e.g. from an eth_call) for the specified function (see getFunction for valid values for key).
Most developers should prefer the parseCallResult method instead, which will automatically detect a CALL_EXCEPTION and throw the corresponding error.
Encodes the transaction revert data for a call result that reverted from the the Contract with the sepcified error (see getError for valid values for fragment) with the values.
This is generally not used by most developers, unless trying to mock a result from a Contract.
Encodes the tx.data for a transaction that calls the function specified (see getFunction for valid values for fragment) with the values.
Encodes the result data (e.g. from an eth_call) for the specified function (see getFunction for valid values for fragment) with values.
This is generally not used by most developers, unless trying to mock a result from a Contract.
Get the ErrorFragment for key, which may be an error selector, error name or error signature that belongs to the ABI.
If values is provided, it will use the Typed API to handle ambiguous cases where multiple errors match by name.
If the key and values do not refine to a single error in the ABI, this will throw.
Get the EventFragment for key, which may be a topic hash, event name or event signature that belongs to the ABI.
If values is provided, it will use the Typed API to handle ambiguous cases where multiple events match by name.
If the key and values do not refine to a single event in the ABI, this will throw.
Get the FunctionFragment for key, which may be a function selector, function name or function signature that belongs to the ABI.
If values is provided, it will use the Typed API to handle ambiguous cases where multiple functions match by name.
If the key and values do not refine to a single function in the ABI, this will throw.
Returns true if key (an event topic hash, event name or event signature) is present in the ABI.
In the case of an event name, the name may be ambiguous, so accessing the EventFragment may require refinement.
Returns true if key (a function selector, function name or function signature) is present in the ABI.
In the case of a function name, the name may be ambiguous, so accessing the FunctionFragment may require refinement.
When using the interface.parseLog to automatically match a Log to its event for parsing, a LogDescription is returned.
When using the interface.parseTransaction to automatically match a transaction data to its function for parsing, a TransactionDescription is returned.
A Typed object allows a value to have its type explicitly specified.
For example, in Solidity, the value 45 could represent a uint8 or a uint256. The value 0x1234 could represent a bytes2 or bytes.
Since JavaScript has no meaningful way to explicitly inform any APIs which what the type is, this allows transparent interoperation with Soldity.
Returns true and provides a type guard is this is a TypedBigInt.
Returns true and provides a type guard is this is a TypedString.