Note: The script must be run in an environment with web3 installed. If web3 is not installed, please refer to the following blog post.
CentOS 7 environment web3 installation and object creation_m0_47233175's blog-CSDN blog https://blog.csdn.net/m0_47233175/article/details/121960931 The script code is as follows
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
var arguments = process.argv.splice(2);
if(!arguments || arguments.length != 2){
console.log("Parameter error!");
return;
}
var _from = arguments[0];
var _to = arguments[1];
var _value = arguments[2];
web3.eth.sendTransaction({from: _from, to: _to, value: _value}, (err, res)=>{
if(err)
console.log("Error: ", err);
else
console.log("Tx: ", res);
});
Copy the above script code into a new transfer_script.js file
run script
node transfer_script.js 0x6903269a98f6ef7ea7190fc0122d5e15ddd25526 0x456982ded2a3eb889b3c3774e48de7fd867c0e5a 10000000
Note: The first parameter after the js file name is the sending address of Ether , the second parameter is the receiving address of Ether , and the third parameter is the number of Ether transactions .
Please make sure the private chain starts in rpc mode
Please make sure the trading account is unlocked