Skip to content

Instantly share code, notes, and snippets.

@hm0429
Created March 7, 2018 14:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hm0429/7ac2241fb3fd9b5c1359c655eb5e7245 to your computer and use it in GitHub Desktop.
// npm install web3
var Web3 = require('web3');
var web3 = new Web3('wss://ropsten.infura.io/ws');
console.log(web3.version)
// 0x9490d2d67f5455d6b1772a928cb1f3f05f2db32a
var privateKey = '0x1A6EDBD9EC44934671718982671A2E2B7A2573430BFEACEA65EB54E7F765442E';
var weiValue = web3.utils.toWei('0.001', 'ether');
var tx = {
to: '0x14ef8277775c680ac000443e9bde9dbb74a7ee74',
value: weiValue,
gasPrice: 20000000000,
gas: 2000000
}
web3.eth.accounts.signTransaction(tx, privateKey, function(error, result) {
console.log(error);
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment