Last active
March 29, 2021 18:57
-
-
Save fbslo/3548df431423b892d9fdd0ec035d395e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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