Created
July 11, 2017 22:18
-
-
Save tinybike/2ff5ecb1c3c3626399a116de4cbcbf6f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/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