Here you have a very simple website that, when run, allows you to connect your MetaMAsk and interact.
Use it to learn what the different parameters are; and how MetaMask builds a transaction in JavaScript.
Deploy a Ropsten node on Chainstack and use it as an endpoint for your MetaMask. Follow this link for instructions, Chainstack on MetaMask.
This way, you will be able to see the requests sent from MetaMask to the node on the Chainstack dashboard.
How to run this webpage
To serve the webpage, you can use a simple node server. Follow these instructions:
- 1 - Install Node.js - Download and instructions.
- 2 - Install lite-server (with NPM in a terminal/command prompt).
npm install -g lite-server
Now, you have the tools to serve a webpage on localhost.
- 1 - Create a new folder where you will save and run this project.
- 2 - Open the folder in a code editor, like Atom or VS Code.
- 3 - Create a new file called
index.html
.- 4 - Paste the code from this Gist into the new file and save it.
- 5 - Serve the webpage via terminal/command prompt from the directory that has
index.html
in it and run:lite-server
Now, your webpage will be available on http://127.0.0.1:3000/.
Try to modify the parameters inside the sendTransaction()
function to see how MetaMask reacts to the changes.
These are the parameters "out of the box":
let params = [{
"from": accounts[0],
"to": '0x8f8e7012F8F974707A8F11C7cfFC5d45EfF5c2Ae',
"value": '0xDE0B6B3A7640000',
//"gasPrice": '0x09184e72a000',
//"gas": '0x2710',
Where:
"from": accounts[0]
, is the account that will send the transaction. In this case, the address selected in your MetaMask.
"to": '0x8f8e7012F8F974707A8F11C7cfFC5d45EfF5c2Ae'
, is the address receiving the transaction. Replace it with one of your addresses. You can keep this one if you want, but make sure you only send testnet funds!
"value": '0xDE0B6B3A7640000'
, is the amount of ETH transferred. In this case, 1 ETH. It must be hex encoded, starting with "0x".
"gasPrice": '0x09184e72a000'
and "gas": '0x2710'
are optional because MetaMask estimates the proper values from the network. You can try to modify them and see how they change the transaction validation!
Remember that the value passed into the function must be a Wei value encoded in hex, starting with "0x".
Use this website to convert to/from Wei.
Use this website to convert decimals to/from hex.