API Reference
API Reference
Extension Version
To get the installed extension version, use the following code.
Connect
For the initial connection to the wallet, use the connect method. It requests access to the site from the user and returns the current account address. If you already have access to the site, it will also return the current account address.
To check if any wallet is connected to the page, use the isConnected
method.
To disconnect the current account from the site, use the disconnect
method.
Important: all methods that require permission from the user will stop working, but the entry in the "Connected Sites" list of the account will not disappear. Only the user can remove access completely through the UI. If you call the
disconnect()
method and thenconnect()
, the user will not be asked for permission again. This will only happen if the user manually removes access through the UI
Change Active Account Event
To keep track of when a user changed their account, use the onChangeAccount
method. When the account is changed, it calls the method you passed in the first argument. If the user at some point revokes the extension's access to the site, then this method will also be called.
To keep track of when a user changed network, use the onChangeNetwork
method. When the network is changed, it calls the method you passed in the first argument.
To get the current connected network, use the network
method.
To get the current chainId, use the chainId
method.
Get Current Account
To get the address of the current account, use the account
method.
To get the public key of the current account , use the publicKey
method.
Sign and Submit Transaction
To request a signature and send a transaction to the blockchain, use the signAndSubmit
method.
payload
- mandatory parameter containing the transaction body.
otherOptions
- optional parameter that overrides transaction parameters.
Included in >=1.7.0. You can also pass a UInt8Array as transaction arguments, or an array with a
UInt8Array
. This forms a vector, or a vector of vectors.
To request a signature of transaction, use the signTransaction
method.
payload
- mandatory parameter containing the transaction body.
otherOptions
- optional parameter that overrides transaction parameters.
You can also pass a UInt8Array as transaction arguments, or an array with a UInt8Array
. This forms a vector, or a vector of vectors.
To request a signature of message, use the signMessage
method.
Last updated