5ire Wallet Extension - Generic Web3 Injection
This guide will show you how to use the 5ireChain wallet extension to interact with your decentralized application (dApp) that is deployed on 5ireChain - both the native and EVM chains.
Usage 1: Native chain dApp interaction (WASM-based)
The 5ire Wallet extension provides an injected provider to every dApp running on Chrome and Mozilla Firefox.
Steps to connect your dApp with 5ire Wallet Extension:
-
The first step is to install the latest version of the 5ire Wallet extension from the Chrome Store.
-
Check for
window.fire
object, it will be available in your application context. -
Call
window.fire.connect()
method, which is promise based and returns the object with the following values:-
EVM Address: 0xB231a3CFd95ACDDDC92d8c60c405E66A3575d5cc
-
Native Address: 5FUv2eCn2VG6tG4WGptP644kHmjWFXXUe9Rnsfv8ss426Y9Z
-
-
You are now successfully connected to the 5ire Wallet extension.
-
To verify the connection, cross-check the radio icon on the top bar of the extension - the green colour indicates Connected status.
Events
You can subscribe to the following events after connecting the 5ire Wallet extension.
-
accountChanged
This event triggers when a user tries to change an account and create a new account in wallet extension, and provides the latest address to the connected dApp.
-
networkChanged
This event provides the current selected RPC endpoint (e.g. Testnet, Mainnet)
-
connect
This event is triggered when the user is successfully connected to the 5ire Wallet extension.
-
disconnect
This event is triggered when the user is successfully disconnected from the 5ire Wallet extension.
Signing Method
The 5ire Wallet extension provides a native signer, which works with every polka.js library or SDK.
-
Sign Payload
-
signRaw
Usage 2: EVM chain dApp interaction (EVM-based)
The 5ire Wallet extension provides an injected provider to every dApp running on Chrome and Mozilla Firefox browser.
Steps to connect your dApp with 5ire Wallet Extension:
-
Check if you have installed the latest version of the 5ire Wallet extension from the Chrome Store.
-
Check for
window.fire
object, it will be available in your application context. -
Call
window.fire.request({method:”eth_requestAccounts”})
method, which is promise-based and returns an array with the following values:- EVM Address:
0xB231a3CFd95ACDDDC92d8c60c405E66A3575d5cc
- EVM Address:
-
You are now successfully connected to the 5ire Wallet extension.
-
To verify the connection, cross-check the radio icon on the top bar of the extension - the green colour indicates “connected” status.
Methods
-
window.ethereum.isfire
-
This property is true if the user has the 5ire Wallet Extension installed. You can also use the 5ire provider with the web3 library.
-
Example: const web3 = new Web3(window.fire);
-
Properties
-
window.fire.request(args)
-
Use this method to submit RPC API requests to 5ireChain using the 5ire Wallet extension. It returns a promise that resolves to the result of the RPC method call.
-
The parameters and return value vary by RPC method. In practice, if a method has parameters, they’re almost always of type
Array{any}
. -
If the request fails, the promise is rejected with an error. The following is an example of using
window.fire.request(args)
to calleth_sendTransaction
:
Events
The 5ire Wallet extension emits events using the Node.js EventEmitter API. The following is an example of listening to the accountChanged
event.
-
accountChanged
-
connect
- The provider emits this event when it’s first able to submit RPC requests to a chain.
-
disconnect
-
The provider emits this event if it becomes unable to submit RPC requests to a chain. In general, this only happens due to network connectivity issues or some unforeseen error.
-
When the provider emits this event, it doesn’t accept new requests until the connection to the chain is re-established, which requires reloading the page.
-