Skip to content

Instantly share code, notes, and snippets.

@tinybike
Created July 11, 2017 22:18
Show Gist options
  • Select an option

  • Save tinybike/2ff5ecb1c3c3626399a116de4cbcbf6f to your computer and use it in GitHub Desktop.

Select an option

Save tinybike/2ff5ecb1c3c3626399a116de4cbcbf6f to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var rpc = require("ethrpc");
var valueToSend = "0x42"; // value to send (in wei, i.e. 1e-18 ether)
var sender = "0x..."; // sending address
var receiver = "0x..."; // receiving address
var privateKey = Buffer.from("...", "hex"); // private key as bytearray (buffer)
rpc.connect({
httpAddresses: [], // ethereum node HTTP endpoint
wsAddresses: [], // ethereum node websocket endpoint
ipcAddresses: [] // ethereum node IPC endpoint
}, () => {
rpc.packageAndSignRawTransaction({
from: sender,
to: receiver,
value: valueToSend,
returns: "null",
gas: "0xcf08"
}, sender, privateKey, (signedRawTransaction) => {
console.log("signed raw transaction:", signedRawTransaction);
rpc.sendRawTransaction(signedRawTransaction, (rpcResponse) => {
console.log("response from ethereum node:", rpcResponse);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment