Contract
A BaseContract with no type guards on its methods or events.
Extends
BaseContract
<this
> &Omit
<ContractInterface
, keyofBaseContract
>
Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
fallback | readonly | null | WrappedFallback | The fallback or receive function if any. | _ContractBase().fallback |
filters | readonly | Record <string , ContractEvent <any []>> | All the Events available on this contract. | _ContractBase().filters |
interface | readonly | Interface | The contract Interface. | _ContractBase().interface |
runner | readonly | null | ContractRunner | The 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. | _ContractBase().runner |
target | readonly | string | Addressable | The 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. | _ContractBase().target |
Methods
addListener()
addListener(event, listener): Promise<Contract>
Alias for on.
Parameters
Parameter | Type | Description |
---|---|---|
event | ContractEventName | The event to listen for. |
listener | Listener | The listener to call when the event is emitted. |
Returns
Promise
<Contract
>
Inherited from
_ContractBase().addListener
Source
attach()
attach(target): BaseContract
Return a new Contract instance with the same ABI and runner, but a different target
.
Parameters
Parameter | Type | Description |
---|---|---|
target | string | Addressable | The target to connect to. |
Returns
The new contract instance.
Inherited from
_ContractBase().attach
Source
connect()
connect(runner): BaseContract
Return a new Contract instance with the same target and ABI, but a different runner
.
Parameters
Parameter | Type | Description |
---|---|---|
runner | null | ContractRunner | The runner to use. |
Returns
The new contract instance.
Inherited from
_ContractBase().connect
Source
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
.
Inherited from
_ContractBase().deploymentTransaction
Source
emit()
emit(event, ...args): Promise<boolean>
Emit an event
calling all listeners with args
.
Resolves to true
if any listeners were called.
Parameters
Parameter | Type | Description |
---|---|---|
event | ContractEventName | The event to emit. |
…args | any [] | The arguments to pass to the listeners. |
Returns
Promise
<boolean
>
true
if any listeners were called.
Inherited from
_ContractBase().emit
Source
getAddress()
getAddress(): Promise<string>
Return the resolved address of this Contract.
Returns
Promise
<string
>
The resolved address.
Inherited from
_ContractBase().getAddress
Source
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.
Inherited from
_ContractBase().getDeployedCode
Throws
If the runner does not support .provider.
Source
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
Parameter | Type | Description |
---|---|---|
key | string | EventFragment | The name of the event to return. |
Returns
ContractEvent
<any
[]>
The event for the given name.
Inherited from
_ContractBase().getEvent
Source
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 parameter | Value |
---|---|
T extends ContractMethod <any [], any , any , T > | ContractMethod <any [], any , any > |
Parameters
Parameter | Type | Description |
---|---|---|
key | string | FunctionFragment | The name of the function to return. |
Returns
T
The function for the given name.
Inherited from
_ContractBase().getFunction
Source
listenerCount()
listenerCount(event?): Promise<number>
Resolves to the number of listeners of event
or the total number of listeners if unspecified.
Parameters
Parameter | Type | Description |
---|---|---|
event ? | ContractEventName | The event to count listeners for. |
Returns
Promise
<number
>
The number of listeners.
Inherited from
_ContractBase().listenerCount
Source
listeners()
listeners(event?): Promise<Listener[]>
Resolves to the listeners subscribed to event
or all listeners if unspecified.
Parameters
Parameter | Type | Description |
---|---|---|
event ? | ContractEventName | The event to get listeners for. |
Returns
Promise
<Listener
[]>
The listeners.
Inherited from
_ContractBase().listeners
Source
off()
off(event, listener?): Promise<Contract>
Remove the listener
from the listeners for event
or remove all listeners if unspecified.
Parameters
Parameter | Type | Description |
---|---|---|
event | ContractEventName | The event to remove the listener from. |
listener ? | Listener | The listener to remove. |
Returns
Promise
<Contract
>
This contract instance.
Inherited from
_ContractBase().off
Source
on()
on(event, listener): Promise<Contract>
Add an event listener
for the event
.
Parameters
Parameter | Type | Description |
---|---|---|
event | ContractEventName | The event to listen for. |
listener | Listener | The listener to call when the event is emitted. |
Returns
Promise
<Contract
>
This contract instance.
Inherited from
_ContractBase().on
Source
once()
once(event, listener): Promise<Contract>
Add an event listener
for the event
, but remove the listener after it is fired once.
Parameters
Parameter | Type | Description |
---|---|---|
event | ContractEventName | The event to listen for. |
listener | Listener | The listener to call when the event is emitted. |
Returns
Promise
<Contract
>
Inherited from
_ContractBase().once
Source
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
Parameter | Type | Description |
---|---|---|
event | ContractEventName | The event to query. |
fromBlock ? | BlockTag | The block to start querying from. |
toBlock ? | BlockTag | The block to stop querying at. |
Returns
An array of event logs.
Inherited from
_ContractBase().queryFilter
Source
removeAllListeners()
removeAllListeners(event?): Promise<Contract>
Remove all the listeners for event
or remove all listeners if unspecified.
Parameters
Parameter | Type | Description |
---|---|---|
event ? | ContractEventName | The event to remove the listeners from. |
Returns
Promise
<Contract
>
This contract instance.
Inherited from
_ContractBase().removeAllListeners
Source
removeListener()
removeListener(event, listener): Promise<Contract>
Alias for off.
Parameters
Parameter | Type | Description |
---|---|---|
event | ContractEventName | The event to remove the listener from. |
listener | Listener | The listener to remove. |
Returns
Promise
<Contract
>
Inherited from
_ContractBase().removeListener
Source
waitForDeployment()
waitForDeployment(): Promise<Contract>
Resolve to this Contract once the bytecode has been deployed, or resolve immediately if already deployed.
Returns
Promise
<Contract
>
The contract instance.
Inherited from
_ContractBase().waitForDeployment
Throws
If the contract runner does not support .provider.
Source
Was this page helpful?