Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let metamaskTx = async () => {
- console.log("is metamask" , ethereum.isMetaMask) // true
- let accounts = await ethereum.enable()
- console.log(ethereum.selectedAddress) // prints selected address
- console.log(ethereum.networkVersion) // prints network ID
- // ethereum.eth is undefined
- let balance = await ethereum.eth.getBalance(ethereum.selectedAddress)
- console.log(balance)
- let transactionParameters = {
- to: '0xe58db6b23575a93c185f756618f8e42745d7292b',
- value: '0x1'
- }
- // fails with RPC Error: Error: Transaction from address isn't valid for this account
- ethereum.sendAsync({
- method: 'eth_sendTransaction',
- params: [transactionParameters],
- from: ethereum.selectedAddress,
- }, function(err, res){
- console.log({err})
- console.log({res})
- })
- }
Add Comment
Please, Sign In to add comment