Welcome to MapNode Extension Wallet Developer Guide. This documentation contains guides for developers to get started developing on MapNode Extension Wallet.
Notice: MapNode Extension Testnet is under development and not available now. The MapNode Extension on Ethereum JavaScript provider API is specified by . Support window.ethereum only and removal window.web3
To connect MapNode Extension Wallet
To connect MapNode Extension means to access the user's [blockchain - like Ethereum] account(s).
// Connect & get accounts
window.ethereum.request({method: 'eth_accounts'});
// Alias for connection
window.ethereum.request({method: 'eth_requestAccounts'});
//Check if dapp connected
window.ethereum.isConnected();
//Check if the caller's current permissions
window.ethereum.request({method: 'wallet_getPermissions'});
//Check if request the given permissions
window.ethereum.request({method: 'wallet_requestPermissions'});
To disconnect MapNode Extension Wallet
To disconnect MapNode Extension, please use:
window.ethereum.disconnect()
To experience functions
Once your account is connected, let's start experiencing more functions.
Get Current Account
return Promise<Array[String]>
If wallet can not be found, return [] instead of throw Error
window.ethereum.request({ method: 'eth_accounts' }).then(accounts => {
if (accounts[0]) {
// Do something with accounts
} else {
// Wallet not found
}
})
Check wallet whether exists or not
return Promise<{data: Boolean}>
window.ethereum.request({ method: 'has_wallet', params: ['harmony'] })
// Example
window.ethereum.request({ method: 'has_wallet', params: ['harmony'] }).then(() => {
// Wallet Exists
}).catch(e => {
// Wallet not found
})
You can connect and receive multiChain address at the same time by using the following methods
async function connect(){
if(!window.MapNode ){
throw new Error('MapNode Extension is required');
}
const accounts = await window.MapNode.connect([<chain 1>, <chain 2>, ...]);
if(!accounts){
throw new Error('Connect Error | User cancel your request');
}
// Do anything with accounts:[<address of chain 1>, <address of chain 2>]
}
When your connection is success, chain's properties will be available for your next request. For example:
// For example | connect ether & solana
async function connect(){
const conn = await window.MapNode.connect(['ether','solana']);
// If user accept the request, those properties will available at window.MapNode ;
// window.solana || Checkout document of solana connection guide for more methods;
// window.ether || Checkout document of ether connection guide for more methods;
}
Chain's Name can be found at
const { CHAIN_NAME } = window.MapNode
Subscription
Support subscribe using JSON-RPC notifications. This allows clients to wait for events instead of polling for them. All result will be release at data event.
Methods
// For Subscribe
window.ethereum.request({
method: 'eth_subscribe',
params: ['<type>','<options>']
})
// Its result will be subscription ID which can be used for unsubscribe
// For Unsubscribe
window.ethereum.request({
method: 'eth_unsubscribe',
params: ['<Subscription ID>']
});
Example
// Subscribe for event
const subscriptionID = window.ethereum.request({
method: 'eth_subscribe',
params: ["logs",
{
address: "0x8320fe7702b96808f7bbc0d4a888ed1468216cfd",
topics: ["0xd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902"]}]
})
// You can listen for incoming notifications by
window.ethereum.on("data", data => {
// Do the rest of your work with data
})
To handle events
List of events
Currently we only support some action event from wallet extension