Skip to content

Instantly share code, notes, and snippets.

@val314159
Created March 21, 2022 23:11
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 val314159/bbad1178e5b3257244639009ecf14052 to your computer and use it in GitHub Desktop.
Save val314159/bbad1178e5b3257244639009ecf14052 to your computer and use it in GitHub Desktop.
create.js
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