This tutorial will show developers how to interact with PlatON WASM contract using MetaMask plugin wallet, it also applies to EVM contracts.
- OS: Windows 10/Ubuntu 18.04
- node: 12.22.8
- web browser: firefox/chrome
git clone firstname.lastname@example.org:hthuang996/platon-wasm-metamask-demo.git cd platon-wasm-metamask-demo npm install
- start web server
npm run serve
The following information will be printed
> static-server . --port 9011 options.index is now deprecated please use options.templates.index instead. * Static server successfully started. * Serving files at: http://localhost:9011 * Press Ctrl+C to shutdown.
install metamask plugin in your browser
You can find tutorial here.
Import private key into your metamask wallet
Private key used in demo
- Open the web page
You can replace localhost with public IP if you are not testing on the same server.
- connect to wallet
Click ‘CONNECT’ button to connect to metamask wallet.
- Get current connected wallet account information.
Click ‘LAT_ACCOUNTS’ button to get your current connected account address, which is in hex style.
The output should be
- Query the balance of an account
Input the address from which you want to get the balance, then click ‘QUERY’ button.
Note: Here you must input PlatON style address starting with ‘lat’.
Mint token to an account
Input the address you want to send token to, then click ‘MINT’ button.
A MetaMask pop-up windows will appear, it asks you to sign the transaction.
Query balance again
After a while, a message will pop up informing you the transaction is confirmed.
Now, you can query the balance again, you will see the balance increase.
The deployed contract is PRC20 standard WASM contract, you can deploy any other contract using your private key. Of course, you need to modify the code and parameters.
The library is generated from client-sdk-js, you can find the tutorial here.