Creates a new contract connected to target with the abi and optionally connected to a runner to perform operations on behalf of.

Implements

Properties

PropertyModifierTypeDescription
fallbackreadonlynull | WrappedFallbackThe fallback or receive function if any.
filtersreadonlyRecord<string, ContractEvent<any[]>>All the Events available on this contract.
interfacereadonlyInterfaceThe contract Interface.
runnerreadonlynull | ContractRunnerThe connected runner. This is generally a Provider or a
Signer, which dictates what operations are supported.

For example, a Contract connected to a Provider may only execute read-only
operations.
targetreadonlystring | AddressableThe target to connect to.

This can be an address or any Addressable, such as another contract. To get the
resolved address, use the getAddress method.

Methods

addListener()

addListener(event, listener): Promise<BaseContract>

Alias for on.

Parameters

ParameterTypeDescription
eventContractEventNameThe event to listen for.
listenerListenerThe listener to call when the event is emitted.

Returns

Promise<BaseContract>

Implementation of

EventEmitterable.addListener

Source

contract/contract.ts:1490


attach()

attach(target): BaseContract

Return a new Contract instance with the same ABI and runner, but a different target.

Parameters

ParameterTypeDescription
targetstring | AddressableThe target to connect to.

Returns

BaseContract

The new contract instance.

Source

contract/contract.ts:1167


connect()

connect(runner): BaseContract

Return a new Contract instance with the same target and ABI, but a different runner.

Parameters

ParameterTypeDescription
runnernull | ContractRunnerThe runner to use.

Returns

BaseContract

The new contract instance.

Source

contract/contract.ts:1157


deploymentTransaction()

deploymentTransaction(): null | ContractTransactionResponse

Return the transaction used to deploy this contract.

This is only available if this instance was returned from a ContractFactor.

Returns

null | ContractTransactionResponse

The transaction used to deploy this contract or null.

Source

contract/contract.ts:1248


emit()

emit(event, ...args): Promise<boolean>

Emit an event calling all listeners with args.

Resolves to true if any listeners were called.

Parameters

ParameterTypeDescription
eventContractEventNameThe event to emit.
argsany[]The arguments to pass to the listeners.

Returns

Promise<boolean>

true if any listeners were called.

Implementation of

EventEmitterable.emit

Source

contract/contract.ts:1379


getAddress()

getAddress(): Promise<string>

Return the resolved address of this Contract.

Returns

Promise<string>

The resolved address.

Implementation of

Addressable.getAddress

Source

contract/contract.ts:1176


getDeployedCode()

getDeployedCode(): Promise<null | string>

Return the deployed bytecode or null if no bytecode is found.

Returns

Promise<null | string>

The deployed bytecode or null.

Throws

If the runner does not support .provider.

Source

contract/contract.ts:1186


getEvent()

getEvent(key): ContractEvent<any[]>

Return the event for a given name. This is useful when a contract event name conflicts with a JavaScript name such as prototype or when using a Contract programatically.

Parameters

ParameterTypeDescription
keystring | EventFragmentThe name of the event to return.

Returns

ContractEvent<any[]>

The event for the given name.

Source

contract/contract.ts:1274


getFunction()

getFunction<T>(key): T

Return the function for a given name. This is useful when a contract method name conflicts with a JavaScript name such as prototype or when using a Contract programatically.

Type parameters

Type parameterValue
T extends ContractMethod<any[], any, any, T>ContractMethod<any[], any, any>

Parameters

ParameterTypeDescription
keystring | FunctionFragmentThe name of the function to return.

Returns

T

The function for the given name.

Source

contract/contract.ts:1259


listenerCount()

listenerCount(event?): Promise<number>

Resolves to the number of listeners of event or the total number of listeners if unspecified.

Parameters

ParameterTypeDescription
event?ContractEventNameThe event to count listeners for.

Returns

Promise<number>

The number of listeners.

Implementation of

EventEmitterable.listenerCount

Source

contract/contract.ts:1389


listeners()

listeners(event?): Promise<Listener[]>

Resolves to the listeners subscribed to event or all listeners if unspecified.

Parameters

ParameterTypeDescription
event?ContractEventNameThe event to get listeners for.

Returns

Promise<Listener[]>

The listeners.

Implementation of

EventEmitterable.listeners

Source

contract/contract.ts:1413


off()

off(event, listener?): Promise<BaseContract>

Remove the listener from the listeners for event or remove all listeners if unspecified.

Parameters

ParameterTypeDescription
eventContractEventNameThe event to remove the listener from.
listener?ListenerThe listener to remove.

Returns

Promise<BaseContract>

This contract instance.

Implementation of

EventEmitterable.off

Source

contract/contract.ts:1438


on()

on(event, listener): Promise<BaseContract>

Add an event listener for the event.

Parameters

ParameterTypeDescription
eventContractEventNameThe event to listen for.
listenerListenerThe listener to call when the event is emitted.

Returns

Promise<BaseContract>

This contract instance.

Implementation of

EventEmitterable.on

Source

contract/contract.ts:1350


once()

once(event, listener): Promise<BaseContract>

Add an event listener for the event, but remove the listener after it is fired once.

Parameters

ParameterTypeDescription
eventContractEventNameThe event to listen for.
listenerListenerThe listener to call when the event is emitted.

Returns

Promise<BaseContract>

Implementation of

EventEmitterable.once

Source

contract/contract.ts:1363


queryFilter()

queryFilter(
   event, 
   fromBlock?, 
toBlock?): Promise<(EventLog | Log)[]>

Provide historic access to event data for event in the range fromBlock (default: 0) to toBlock (default: "latest") inclusive.

Parameters

ParameterTypeDescription
eventContractEventNameThe event to query.
fromBlock?BlockTagThe block to start querying from.
toBlock?BlockTagThe block to stop querying at.

Returns

Promise<(EventLog | Log)[]>

An array of event logs.

Source

contract/contract.ts:1300


removeAllListeners()

removeAllListeners(event?): Promise<BaseContract>

Remove all the listeners for event or remove all listeners if unspecified.

Parameters

ParameterTypeDescription
event?ContractEventNameThe event to remove the listeners from.

Returns

Promise<BaseContract>

This contract instance.

Implementation of

EventEmitterable.removeAllListeners

Source

contract/contract.ts:1465


removeListener()

removeListener(event, listener): Promise<BaseContract>

Alias for off.

Parameters

ParameterTypeDescription
eventContractEventNameThe event to remove the listener from.
listenerListenerThe listener to remove.

Returns

Promise<BaseContract>

Implementation of

EventEmitterable.removeListener

Source

contract/contract.ts:1500


waitForDeployment()

waitForDeployment(): Promise<BaseContract>

Resolve to this Contract once the bytecode has been deployed, or resolve immediately if already deployed.

Returns

Promise<BaseContract>

The contract instance.

Throws

If the contract runner does not support .provider.

Source

contract/contract.ts:1205


buildClass()

static buildClass<T>(abi): Object

Create a new Class for the abi.

Type parameters

Type parameterValue
TContractInterface

Parameters

ParameterTypeDescription
abiInterface | InterfaceAbiThe ABI to create the class from.

Returns

Object

The new Class for the ABI.

Source

contract/contract.ts:1510


from()

static from<T>(
   target, 
   abi, 
runner?): BaseContract & Omit<T, keyof BaseContract>

Create a new BaseContract with a specified Interface.

Type parameters

Type parameterValue
TContractInterface

Parameters

ParameterTypeDescription
targetstringThe target to connect to.
abiInterface | InterfaceAbiThe ABI to use.
runner?null | ContractRunnerThe runner to use.

Returns

BaseContract & Omit<T, keyof BaseContract>

The new BaseContract.

Source

contract/contract.ts:1529