W3MService class

Either a projectId and metadata must be provided or an already created web3App. optionalNamespaces is mostly not needed, if you use it, the values set here will override every optionalNamespaces set in evey chain

Implemented types
Mixed-in types

Constructors

W3MService({BuildContext? context, IWeb3App? web3App, String? projectId, PairingMetadata? metadata, SIWEConfig? siweConfig, Map<String, W3MNamespace>? requiredNamespaces, Map<String, W3MNamespace>? optionalNamespaces, Set<String>? featuredWalletIds, Set<String>? includedWalletIds, Set<String>? excludedWalletIds, bool? enableAnalytics, bool enableEmail = false, LogLevel logLevel = LogLevel.nothing})
context is required if SIWEConfig is passed.

Properties

avatarUrl String?
The url to the account's avatar image. Pass this into a Image.network and it will load the avatar image.
no setteroverride
balanceNotifier ValueNotifier<String>
final
chainBalance String
Returns the balance of the currently connected wallet on the selected chain.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
hasNamespaces bool
no setteroverride
isConnected bool
Variable that can be used to check if the web3App is connected
no setteroverride
isOpen bool
Variable that can be used to check if the modal is visible on screen.
no setteroverride
modalContext BuildContext?
no setteroverride
onModalConnect Event<ModalConnect>
final
onModalDisconnect Event<ModalDisconnect>
final
onModalError Event<ModalError>
final
onModalNetworkChange Event<ModalNetworkChange>
final
onModalUpdate Event<ModalConnect>
final
onSessionEventEvent Event<SessionEvent>
final
onSessionExpireEvent Event<SessionExpire>
final
onSessionUpdateEvent Event<SessionUpdate>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedChain W3MChainInfo?
The currently selected chain.
no setteroverride
selectedWallet W3MWalletInfo?
The currently selected wallet.
no setteroverride
session W3MSession?
The current session's data.
no setteroverride
status W3MServiceStatus
Whether or not this object has been initialized.
no setteroverride
wcUri String?
The URI that can be used to connect to this dApp. This is only available after the openModalView function is called.
no setteroverride
web3App IWeb3App?
The object that manages sessions, authentication, events, and requests for WalletConnect.
no setteroverride

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
buildConnectionUri() Future<void>
This will do nothing if isConnected is true.
override
closeModal({bool disconnectSession = false}) → void
Closes the modal.
override
connectSelectedWallet({bool inBrowser = false}) Future<void>
Connects the selectedWallet previously selected
override
disconnect({bool disconnectAllSessions = true}) Future<void>
Disconnects the session and pairing, if any. If there is no session, this does nothing.
override
dispose() Future<void>
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
expirePreviousInactivePairings() Future<void>
Used to expire and delete any inactive pairing
override
getApprovedChains() List<String>?
Will get the list of already approved chains by the wallet (to switch to)
override
getApprovedEvents() List<String>?
List of approved events by connected wallet
override
getApprovedMethods() List<String>?
List of approved methods by connected wallet
override
getAvailableChains() List<String>?
Will get the list of available chains to add
override
init() Future<void>
Sets up the explorer and the web3App if they already been initialized.
override
launchBlockExplorer() → void
Launch blockchain explorer for the current chain in external browser
override
launchConnectedWallet() → void
Opens the native wallet selectedWallet after connected
override
loadAccountData() Future<void>
Loads account balance and avatar. Returns true if it was able to actually load data (i.e. there is a selected chain and session)
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
openModal(BuildContext context, [Widget? startWidget]) Future<void>
Opens the modal with the provided startWidget (if any). If none is provided, the default state will be used based on platform.
override
openModalView([Widget? startWidget]) Future<void>
override
openNetworks(BuildContext context) Future<void>
override
openNetworksView() Future<void>
override
reconnectRelay() Future<void>
Connects to the relay if not already connected. If the relay is already connected, this does nothing.
override
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
request({required String? topic, required String chainId, required SessionRequestParams request, String? switchToChainId}) Future
Make a request
override
requestAddChain(W3MChainInfo newChain) Future<void>
override
requestReadContract({required String? topic, required String chainId, required DeployedContract deployedContract, required String functionName, EthereumAddress? sender, List parameters = const []}) Future<List>
override
requestSwitchToChain(W3MChainInfo newChain) Future<void>
override
requestWriteContract({required String? topic, required String chainId, required DeployedContract deployedContract, required String functionName, required Transaction transaction, List parameters = const [], String? method}) Future
override
selectChain(W3MChainInfo? chainInfo, {bool switchChain = false, bool logEvent = true}) Future<void>
Sets the selectedChain and gets the chainBalance. If the wallet is already connected, it will request the chain to be changed and will update the session with the new chain. If chainInfo is null this will disconnect the wallet.
override
selectWallet(W3MWalletInfo? walletInfo) → void
Sets the selectedWallet to be connected
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited