Ethereum class
A Dart Ethereum Provider API for consistency across clients and applications.
- Available extensions
Properties
- autoRefreshOnNetworkChange ← bool
-
no getter
- chainId → String
-
Returns a hexadecimal string representing the current chain ID.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- impl → _EthereumImpl
-
Internal JS Object, should not be used directly.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedAddress → String?
-
Returns first getAccounts item but may return unexpected value.
no setter
Methods
-
getAccounts(
) → Future< List< String> > - Returns List of accounts the node controls.
-
getChainId(
) → Future< int> - Returns chain id in int
-
isConnected(
) → bool -
Returns
true
if the provider is connected to the current chain, andfalse
otherwise. -
listenerCount(
[String? eventName]) → int -
Returns the number of listeners for the
eventName
events. If noeventName
is provided, the total number of listeners is returned. -
listeners(
String eventName) → List -
Returns the list of Listeners for the
eventName
events. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
off(
String eventName, [Function? listener]) → dynamic -
Remove a
listener
for theeventName
event. If nolistener
is provided, all listeners foreventName
are removed. -
on(
String eventName, Function listener) → dynamic -
Add a
listener
to be triggered for eacheventName
event. -
onAccountsChanged(
void listener(List< String> accounts)) → dynamic -
Add a
listener
to be triggered for each accountsChanged event. -
once(
String eventName, Function listener) → dynamic -
Add a
listener
to be triggered for only the nexteventName
event, at which time it will be removed. -
onChainChanged(
void listener(int chainId)) → dynamic -
Add a
listener
to be triggered for each chainChanged event. -
onConnect(
void listener(ConnectInfo connectInfo)) → dynamic -
Add a
listener
to be triggered for each connect event. -
onDisconnect(
void listener(ProviderRpcError error)) → dynamic -
Add a
listener
to be triggered for each disconnect event. -
onMessage(
void listener(String type, dynamic data)) → dynamic -
Add a
listener
to be triggered for each message eventtype
. -
removeAllListeners(
[String? eventName]) → dynamic -
Remove all the listeners for the
eventName
events. If noeventName
is provided, all events are removed. -
request<
T> (String method, [dynamic params]) → Future< T> -
Use request to submit RPC requests with
method
and optionallyparams
to Ethereum via MetaMask or provider that is currently using. -
requestAccount(
) → Future< List< String> > - Request/Enable the accounts from the current environment.
-
toString(
) → String -
A string representation of this object.
override
-
walletAddChain(
{required int chainId, required String chainName, required CurrencyParams nativeCurrency, required List< String> rpcUrls, List<String> ? blockExplorerUrls}) → Future<void> -
Creates a confirmation asking the user to add the specified chain with
chainId
,chainName
,nativeCurrency
, andrpcUrls
to MetaMask. -
walletSwitchChain(
int chainId, [void unrecognizedChainHandler()?]) → Future< void> -
Creates a confirmation asking the user to switch to the chain with the specified
chainId
. -
walletWatchAssets(
{required String address, required String symbol, required int decimals, String? image, String type = 'ERC20'}) → Future< bool> -
Requests that the user tracks the token with
address
,symbol
, anddecimals
in MetaMask,decimals
is optional.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- binanceChain → Ethereum
-
Ethereeum provider api used in Binance Chain Wallet.
no setter
- ethereum → Ethereum
-
Modern Ethereum provider api, injected by many famous environment such as
MetaMask
orTrustWallet
.no setter - isSupported → bool
-
Getter for boolean to detect Ethereum object support. without calling itself to prevent js undefined error.
no setter
- provider → Ethereum?
-
Getter for default Ethereum provider object, cycles through available injector in environment.
no setter
- web3 → Ethereum?
-
Old web3 object, deprecated now.
no setter