Contract class
A Contract is an abstraction of code that has been deployed to the blockchain.
A Contract may be sent transactions, which will trigger its code to be run with the input of the transaction data.
Constructors
- Contract(String address, dynamic abi, dynamic providerOrSigner)
-
Instantiate Contract object for invoking smart contract method.
factory
-
Contract.fromProvider(String address, dynamic abi, Provider<
_ProviderImpl> provider) -
Instantiate Contract from
provider
for read-only contract calls.factory -
Contract.fromSigner(String address, dynamic abi, Signer<
_SignerImpl> signer) -
Instantiate Contract from provider for read-write contract calls.
factory
Properties
- address → String
-
This is the address (or ENS name) the contract was constructed with.
no setter
-
deployTransaction
→ Future<
TransactionResponse> -
If the Contract object is the result of a
ContractFactory
deployment, this is the transaction which was used to deploy the contract.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- impl → _ContractImpl
-
Internal JS Object, should not be used directly.
finalinherited
- interface → Interface
-
This is the ABI as an Interface.
no setter
- isReadOnly → bool
-
true
if connected to Provider,false
if connected to Signer.no setter -
provider
→ Provider<
_ProviderImpl> -
If a Provider was provided to the constructor, this is that provider. If a Signer was provided that had a Provider, this is that provider.
no setter
-
resolvedAddress
→ Future<
String> -
This is a Future that will resolve to the address this is attached to.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
signer
→ Signer<
_SignerImpl> ? -
If a Signer was provided to the constructor, this is that signer.
no setter
Methods
-
attach(
String addressOrName) → Contract -
Returns a new instance of the Contract attached to
addressOrName
. -
call<
T> (String method, [List args = const []]) → Future< T> -
Call read-only constant
method
withargs
. -
connect(
dynamic providerOrSigner) → Contract - Returns a new instance of the Contract, but connected to Provider or Signer.
-
estimateGas(
String method, [List args = const [], TransactionOverride? override]) → Future< BigInt> -
Returns the estimate units of gas that would be required to execute the
method
withargs
andoverride
. -
getFilter(
String eventName, [List args = const []]) → Filter -
Return a filter for
eventName
, optionally filtering by additionalargs
constraints. -
listenerCount(
[dynamic event]) → int -
Returns the number of listeners for the
event
. If noevent
is provided, the total number of listeners is returned. -
listeners(
Object event) → List -
Returns the list of Listeners for the
event
. -
multicall<
T> (String method, List< List> args, [Multicall? multicall, bool eagerError = false]) → Future<List< T> > -
Multicall read-only constant
method
withargs
. Will use multiple https call unless multicall is provided. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
off(
dynamic event, [Function? listener]) → dynamic -
Remove a
listener
for theevent
. If nolistener
is provided, all listeners forevent
are removed. -
on(
dynamic event, Function listener) → dynamic -
Add a
listener
to be triggered for eachevent
. -
once(
dynamic event, Function listener) → dynamic -
Add a
listener
to be triggered for only the nextevent
, at which time it will be removed. -
queryFilter(
EventFilter< _EventFilterImpl> filter, [dynamic startBlock, dynamic endBlock]) → Future<List< Event> > -
Return a List of Log that have been emitted by the Contract by the
filter
. Optinally constraint fromstartBlock
toendBlock
. -
removeAllListeners(
[dynamic event]) → dynamic -
Remove all the listeners for the
event
. If noevent
is provided, all events are removed. -
send(
String method, [List args = const [], TransactionOverride? override]) → Future< TransactionResponse> -
Send write
method
withargs
,override
may be include to send the Ether or adjust transaction options. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited