Created
March 3, 2019 03:50
-
-
Save JesseAbram/c1e982eb99782018dc57afb7fb97cb35 to your computer and use it in GitHub Desktop.
Ethers sending Tx
This file contains 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
const ethers = require('ethers') | |
const { PRIVATE_KEY } = require('./credentials') | |
const provider = new ethers.getDefaultProvider('kovan'); | |
const acc = new ethers.Wallet(PRIVATE_KEY, provider); | |
const amount = ethers.utils.bigNumberify(2000000000000000); | |
const gasPrice = ethers.utils.bigNumberify(6000000000); | |
const gasLimit = ethers.utils.bigNumberify(210000); | |
const to = acc.address; | |
const transaction = async () => { | |
const nonce = await acc.getTransactionCount('pending') | |
const tx = { | |
to, | |
value: amount, | |
gasLimit, | |
gasPrice, | |
nonce | |
} | |
console.log(tx) | |
const raw = await acc.sendTransaction(tx) | |
console.log(raw) | |
} | |
transaction() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment