Created
May 11, 2020 16:17
-
-
Save Sowmayjain/f0001c7af7d40f0eac3e368eef8fd1ec to your computer and use it in GitHub Desktop.
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
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