Getting Started with MetaMask
#
IntroductionMetaMask is a convenient UI for interacting with Ethereum-compatible blockchains (such as Conflux eSpace). For the purpose of this guide, we will assume you are already familiar with MetaMask and have it installed. If you need help getting started with MetaMask itself, check out their documentation.
In this tutorial we will walk through connecting MetaMask to the Conflux eSpace Testnet , deploying a simple ERC-20 contract using Remix, and transferring the new token using MetaMask.
note
Screenshots in this tutorial are taken from the MetaMask browser extension version 10.8.1.
#
Connecting MetaMask to Conflux eSpaceYou can add the Conflux eSpace network to your MetaMask wallet by following these steps:
- Open your browser and navigate to https://chainlist.org.
- Search for "Conflux eSpace".
- Click "Connect Wallet" under "Conflux eSpace" to allow this site to send requests to Metamask.
- Click "Add to Metamask" under "Conflux eSpace".
- When MetaMask prompts "Allow this site to add a network?", click "Approve".
- When MetaMask prompts "Allow this site to switch the network?", click "Approve".
Your MetaMask wallet is now connected to Conflux eSpace. You can switch to other networks anytime through the network selection dropdown menu in MetaMask.
Alternatively, you can add Conflux eSpace to MetaMask manually by selecting "Add Network" (or "Custom RPC") in the network selection drop-down menu:
For the eSpace mainnet, please use the following configuration values:
- Network Name: Conflux eSpace
- New RPC URL: https://evm.confluxrpc.com
- Chain ID: 1030
- Currency Symbol: CFX
- Block Explorer URL: https://evm.confluxscan.net
For the eSpace testnet, please use the following configuration values:
- Network Name: Conflux eSpace (Testnet)
- New RPC URL: https://evmtestnet.confluxrpc.com
- Chain ID: 71
- Currency Symbol: CFX
- Block Explorer URL: https://evmtestnet.confluxscan.net
note
All the Conflux eSpace RPC endpoint URLs and chain IDs can be found on our Networks page.
Click Save
, and you should see Conflux eSpace
is now the network selected in MetaMask.
To see MetaMask in action, we will connect it to Remix and perform some transactions.
The rest of this guide will assume your MetaMask is connected to Conflux eSpace (Testnet)
.
#
Deploying an ERC-20 Token using RemixIn a new tab, open the Remix IDE at remix.ethereum.org.
It might take a minute to load, but once it has, create a new file ERC20Token.sol
in the workspace panel on the left:
Copy and paste the following code into the central editor panel:
Click the Solidity Compile
button on the far left panel (the second icon down);
ensure your selected Solidity compiler version is 0.8 (minor versions within 0.8, e.g., 0.8.4 work too), and click Compile ERC20Token.sol
.
Once the contract is compiled, click the Deploy & run transactions
button in the far left panel (the icon below the Solidity compiler).
In the ENVIRONMENT
drop-down select Injected Web3
.
You will see a MetaMask pop-up window asking you to give the Remix IDE permission to access it.
Click Next
and then Connect
to grant access.
Back in the Remix interface, click the arrow next to the DEPLOY
section of the left panel.
Fill in the token details with whatever you like (GoldenToken
and GLD
in the example), and click transact
.
Another MetaMask pop-up will appear asking you to confirm the transaction.
Click Confirm
.
After a few moments the transaction will be confirmed by the network.
You will see a success message in the bottom panel and the contract listed under Deployed Contracts
on the left panel.
Click the copy button to copy the address of the newly deployed contract.
Now that the contract is deployed on the Conflux eSpace, we can interact with it via MetaMask.
#
Adding an ERC-20 Token to MetaMaskIn the MetaMask interface (with the Conflux EVM Testnet network still selected), click the Add Token
button:
Paste the token address copied from Remix in the previous step.
The remaining token details should fill in automatically as MetaMask finds the contract on-chain.
Click Next
:
On the next screen you see the balance (100 tokens), as minted in our contract constructor.
Click Add Tokens
:
The token has now been added to MetaMask and we can use the MetaMask interface to view the token balance and to transfer the token to others.
#
Transferring an ERC-20 Token with MetaMaskContinuing from the previous step, click the Send
button in the MetaMask interface:
Select a recipient (if you have multiple accounts in MetaMask you can simply select another account), and an amount of tokens to send.
Click Next
:
note
Once again the gas price should be set to zero, but this will change going forward.
Click Confirm
to send the transaction to the network:
After a few moments the transaction will be confirmed by the network. You can see the updated balance your account holds in the MetaMask interface:
If you transferred to another MetaMask account you hold then you can follow the aforementioned instructions for adding the token to MetaMask on the other account, and view its balance also.
#
SummaryIn this tutorial we connected MetaMask to the Conflux EVM Testnet, deployed an ERC-20 token contract using Remix, and transferred that token using MetaMask. The only difference to doing this on the original Ethereum network was setting the RPC endpoint to be Conflux eSpace's.