Skip to content

Instantly share code, notes, and snippets.

@JesseAbram
Created March 3, 2019 03:50
Show Gist options
  • Save JesseAbram/c1e982eb99782018dc57afb7fb97cb35 to your computer and use it in GitHub Desktop.
Save JesseAbram/c1e982eb99782018dc57afb7fb97cb35 to your computer and use it in GitHub Desktop.
Ethers sending Tx
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