Created
March 21, 2022 23:11
-
-
Save val314159/bbad1178e5b3257244639009ecf14052 to your computer and use it in GitHub Desktop.
create.js
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 Web3 = require('web3'); | |
let { API_URL, FROM, AMT } = process.env; | |
if(FROM[0]=='"') | |
FROM = FROM.substr(1,FROM.length-2); | |
const URL = API_URL || "ws://localhost:8546"; | |
const web3 = new Web3(URL); | |
web3.eth.accounts.wallet.create(3, '54674321§3456764321§345674321§3453647544±±±§±±±!!!43534534534534'); | |
async function send2(from, address, amt) { | |
const nonce = await web3.eth.getTransactionCount(from, 'latest'); // nonce starts counting from 0 | |
const transaction = { | |
'from': from, | |
'to': address, // faucet address to return eth | |
'value': amt, | |
'gas': 30000, | |
// 'maxFeePerGas': 1000000108, | |
'nonce': nonce, | |
// optional data field to send message or execute smart contract | |
}; | |
await web3.eth.sendTransaction(transaction); | |
} | |
(async function main(){ | |
console.log('#!/bin/bash'); | |
console.log(`unset WALLET`); | |
console.log(`export WEB3_PROVIDER_URI=${URL}`); | |
console.log("export PATH=${PATH}:./out/"); | |
for(var n=0; n<x.length; n++){ | |
if(n==0){ | |
console.log(`export PUBLIC=${x[n].address}`); | |
console.log(`export PRIVATE=${x[n].privateKey.substr(2)}`); | |
console.log(``); | |
} | |
console.log(`export PUB${n}=${x[n].address}`); | |
console.log(`export PRV${n}=${x[n].privateKey.substr(2)}`); | |
await send2(FROM, x[n].address, AMT || "98765431000000000000000000"); | |
} | |
console.log('"$@"'); | |
process.exit(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment