Skip to content

Instantly share code, notes, and snippets.

@fbslo
Last active March 29, 2021 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbslo/3548df431423b892d9fdd0ec035d395e to your computer and use it in GitHub Desktop.
Save fbslo/3548df431423b892d9fdd0ec035d395e to your computer and use it in GitHub Desktop.
async function sendTx(){
let accounts = await ethereum.request({ method: 'eth_requestAccounts' });
let your_address = ''
let amount = 1
const transactionParameters = {
nonce: '0x00', // ignored by MetaMask
to: your_address, // Required except during contract publications.
from: accounts[0], // must match user's active address.
chainId: 1, // Used to prevent transaction reuse across blockchains. Auto-filled by MetaMask.
gas: '0x186A0',
value: (amount * Math.pow(10, 18)).toString()
};
console.log(transactionParameters)
const txHash = await ethereum.request({
method: 'eth_sendTransaction',
params: [transactionParameters],
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment