MetaMask
In this doc, dapp developers can learn about the integration of MetaMask into their Rangers Protocol dapp with web3.js.
MetaMask is an open source Ethereum wallet that helps users easily manage their digital assets.In addition, it can help test smart contract functions, support most Dapps, be compatible with hardware wallets, and send coins with one click.
MetaMask holds a dialogue with Web3 RPC or API on the Rangers Protocol node, and the MetaMask connection is based on a similar Ethereum function, it is possible to reconfigure MetaMask in a way similar to Ethereum. That is, in the settings of MetaMask, you can access a node based on the Rangers Protocol by adding a new network.
web3.js config
Step 1 Install web3
In order to better serve the dapps on Rangers Protocol, it is recommended that you install web3 under your DApp. Learn how to add web3.js into your dapp here.
Step 2 Web3 Call
Create a new file named “web3.js” and paste the following code into it
The web3 instance in the above code requests access to the MetaMask account by detecting a global object (ethereum or web3) injected by MetaMask. According to the Metamask API Documentation : MetaMask injects a global API into websites visited by its users at window.ethereum. This API allows websites to request users' Ethereum accounts, read data from blockchains the user is connected to, and suggest that the user sign messages and transactions. The presence of the provider object indicates an Ethereum user. In simple terms, it can help instantiate our web3 object.
Metamask Wallet Setup
Set MetaMask on your browser
Metamask provides plug-in functions that can be used in the browser, which greatly frees up your computer memory. It supports chrome, firefox, edge and Brave. The following will use chrome as a tutorial. In the chrome web store, search for MetaMask in the chrome web store
click “add to chrome” , then MetaMask will be download automatically Create a wallet
Create password
Secure your wallet, watch a video to learn how to keep your wallet safe.
Reveal and remember your secret recovery phrase
Test
Confirm and All done!
Export private key
Enter the MetaMask homepage and click“Account details”
Export the private key
Enter your password and get private key
Add the Rangers Protocol into MetaMask
The necessary step of sending transaction is to add the Rangers Protocol into the MetaMask, and the detailed demonstration instructions would be helpful when in practice.
Last updated