Skip to content

Instantly share code, notes, and snippets.

@Sowmayjain
Created May 11, 2020 16:17
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 Sowmayjain/f0001c7af7d40f0eac3e368eef8fd1ec to your computer and use it in GitHub Desktop.
Save Sowmayjain/f0001c7af7d40f0eac3e368eef8fd1ec to your computer and use it in GitHub Desktop.
require('dotenv').config()
const Web3 = require('web3')
const DSA = require("dsa-sdk");
const web3 = new Web3(new Web3.providers.HttpProvider(process.env.INFURA_ETH_NODE_URL))
const dsa = new DSA({
web3: web3,
mode: "node",
privateKey: process.env.WALLET_PRIVATE_KEY
});
async function getTxnCount() {
return await web3.eth.getTransactionCount(process.env.WALLET_ADDRESS);
}
const gasLimit = "2000000"
const gasPrice = "20";
async function buildWallet() {
const nonce = await getTxnCount();
dsa.build({
gasLimit: web3.utils.toHex(gasLimit),
gasPrice: web3.utils.toHex(web3.utils.toWei(gasPrice, 'gwei')),
nonce: nonce
}).then(txHash => {
console.log(`https://etherscan.io/tx/${txHash}`)
})
}
buildWallet();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment