Interface
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:170
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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Interface(fragments): Interface;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:191
Create a new Interface for the %%fragments%%.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragments | InterfaceAbi |
Returns
Section titled “Returns”Interface
Properties
Section titled “Properties”deploy
Section titled “deploy”readonly deploy: ConstructorFragment;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:179
The Contract constructor.
fallback
Section titled “fallback”readonly fallback: | null | FallbackFragment;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:183
The Fallback method, if any.
fragments
Section titled “fragments”readonly fragments: readonly Fragment[];
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:175
All the Contract ABI members (i.e. methods, events, errors, etc).
receive
Section titled “receive”readonly receive: boolean;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:187
If receiving ether is supported.
Methods
Section titled “Methods”_decodeParams()
Section titled “_decodeParams()”_decodeParams(params, data): Result;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:279
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
params | readonly ParamType [] |
data | BytesLike |
Returns
Section titled “Returns”_encodeParams()
Section titled “_encodeParams()”_encodeParams(params, values): string;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:280
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
params | readonly ParamType [] |
values | readonly any [] |
Returns
Section titled “Returns”string
decodeErrorResult()
Section titled “decodeErrorResult()”decodeErrorResult(fragment, data): Result;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:295
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragment | | string | ErrorFragment |
data | BytesLike |
Returns
Section titled “Returns”decodeEventLog()
Section titled “decodeEventLog()”decodeEventLog( fragment, data, topics?): Result;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:345
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragment | | string | EventFragment |
data | BytesLike |
topics? | readonly string [] |
Returns
Section titled “Returns”decodeFunctionData()
Section titled “decodeFunctionData()”decodeFunctionData(fragment, data): Result;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:313
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragment | | string | FunctionFragment |
data | BytesLike |
Returns
Section titled “Returns”decodeFunctionResult()
Section titled “decodeFunctionResult()”decodeFunctionResult(fragment, data): Result;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:329
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragment | | string | FunctionFragment |
data | BytesLike |
Returns
Section titled “Returns”encodeDeploy()
Section titled “encodeDeploy()”encodeDeploy(values?): string;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:285
Encodes a tx.data
object for deploying the Contract with
the %%values%% as the constructor arguments.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
values? | readonly any [] |
Returns
Section titled “Returns”string
encodeErrorResult()
Section titled “encodeErrorResult()”encodeErrorResult(fragment, values?): string;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:304
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragment | | string | ErrorFragment |
values? | readonly any [] |
Returns
Section titled “Returns”string
encodeEventLog()
Section titled “encodeEventLog()”encodeEventLog(fragment, values): object;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:341
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragment | | string | EventFragment |
values | readonly any [] |
Returns
Section titled “Returns”object
data: string;
topics
Section titled “topics”topics: string[];
encodeFilterTopics()
Section titled “encodeFilterTopics()”encodeFilterTopics(fragment, values): (null | string | string[])[];
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:340
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragment | | string | EventFragment |
values | readonly any [] |
Returns
Section titled “Returns”(null
| string
| string
[])[]
encodeFunctionData()
Section titled “encodeFunctionData()”encodeFunctionData(fragment, values?): string;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:319
Encodes the tx.data
for a transaction that calls the function
specified (see [[getFunction]] for valid values for %%fragment%%) with
the %%values%%.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragment | | string | FunctionFragment |
values? | readonly any [] |
Returns
Section titled “Returns”string
encodeFunctionResult()
Section titled “encodeFunctionResult()”encodeFunctionResult(fragment, values?): string;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:339
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
fragment | | string | FunctionFragment |
values? | readonly any [] |
Returns
Section titled “Returns”string
forEachError()
Section titled “forEachError()”forEachError(callback): void;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:278
Iterate over all errors, calling %%callback%%, sorted by their name.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
callback | (func , index ) => void |
Returns
Section titled “Returns”void
forEachEvent()
Section titled “forEachEvent()”forEachEvent(callback): void;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:263
Iterate over all events, calling %%callback%%, sorted by their name.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
callback | (func , index ) => void |
Returns
Section titled “Returns”void
forEachFunction()
Section titled “forEachFunction()”forEachFunction(callback): void;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:235
Iterate over all functions, calling %%callback%%, sorted by their name.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
callback | (func , index ) => void |
Returns
Section titled “Returns”void
format()
Section titled “format()”format(minimal?): string[];
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:197
Returns the entire Human-Readable ABI, as an array of signatures, optionally as %%minimal%% strings, which removes parameter names and unneceesary spaces.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
minimal? | boolean |
Returns
Section titled “Returns”string
[]
formatJson()
Section titled “formatJson()”formatJson(): string;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:202
Return the JSON-encoded ABI. This is the format Solidiy returns.
Returns
Section titled “Returns”string
getAbiCoder()
Section titled “getAbiCoder()”getAbiCoder(): AbiCoder;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:207
The ABI coder that will be used to encode and decode binary data.
Returns
Section titled “Returns”getError()
Section titled “getError()”getError(key, values?): | null | ErrorFragment;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:274
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
key | string |
values? | any [] |
Returns
Section titled “Returns”| null
| ErrorFragment
getEvent()
Section titled “getEvent()”getEvent(key, values?): | null | EventFragment;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:259
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
key | string |
values? | any [] |
Returns
Section titled “Returns”| null
| EventFragment
getEventName()
Section titled “getEventName()”getEventName(key): string;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:240
Get the event name for %%key%%, which may be a topic hash, event name or event signature that belongs to the ABI.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
key | string |
Returns
Section titled “Returns”string
getFunction()
Section titled “getFunction()”getFunction(key, values?): | null | FunctionFragment;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:231
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
key | string |
values? | any [] |
Returns
Section titled “Returns”| null
| FunctionFragment
getFunctionName()
Section titled “getFunctionName()”getFunctionName(key): string;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:212
Get the function name for %%key%%, which may be a function selector, function name or function signature that belongs to the ABI.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
key | string |
Returns
Section titled “Returns”string
hasEvent()
Section titled “hasEvent()”hasEvent(key): boolean;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:248
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
key | string |
Returns
Section titled “Returns”boolean
hasFunction()
Section titled “hasFunction()”hasFunction(key): boolean;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:220
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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
key | string |
Returns
Section titled “Returns”boolean
makeError()
Section titled “makeError()”makeError(_data, tx): CallExceptionError;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:330
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
_data | BytesLike |
tx | CallExceptionTransaction |
Returns
Section titled “Returns”parseCallResult()
Section titled “parseCallResult()”parseCallResult(data): Result;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:356
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
data | BytesLike |
Returns
Section titled “Returns”parseError()
Section titled “parseError()”parseError(data): | null | ErrorDescription;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:373
Parses a revert data, finding the matching error and extracts the parameter values along with other useful error details.
If the matching error cannot be found, returns null.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
data | BytesLike |
Returns
Section titled “Returns”| null
| ErrorDescription
parseLog()
Section titled “parseLog()”parseLog(log): | null | LogDescription;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:363
Parses a receipt log, finding the matching event and extracts the parameter values along with other useful event details.
If the matching event cannot be found, returns null.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
log | { data : string ; topics : readonly string []; } |
log.data | string |
log.topics | readonly string [] |
Returns
Section titled “Returns”| null
| LogDescription
parseTransaction()
Section titled “parseTransaction()”parseTransaction(tx): | null | TransactionDescription;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:352
Parses a transaction, finding the matching function and extracts the parameter values along with other useful function details.
If the matching function cannot be found, return null.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
tx | { data : string ; value? : BigNumberish ; } |
tx.data | string |
tx.value? | BigNumberish |
Returns
Section titled “Returns”| null
| TransactionDescription
from()
Section titled “from()”static from(value): Interface;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/abi/interface.d.ts:380
Creates a new [[Interface]] from the ABI %%value%%.
The %%value%% may be provided as an existing [[Interface]] object, a JSON-encoded ABI or any Human-Readable ABI format.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
value | | Interface | InterfaceAbi |
Returns
Section titled “Returns”Interface