Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified composer.json
100644 → 100755
Empty file.
Empty file modified composer.lock
100644 → 100755
Empty file.
24 changes: 15 additions & 9 deletions index.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
const Eth = require('ethjs');
const argv = require('yargs').argv;

const ethers = require('ethers');
const sign = require('ethjs-signer').sign;
var Web3 = require('web3');

switch (argv._[0] || '') {
case 'sign':
if (!argv.privateKey || !argv.tx) {
console.error('Missing required parameters');
if (!argv.privateKey || !argv.tx || !argv.rpcEndpoint) {
process.stdout.write('ERROR: Missing required parameters');
return process.exit(1);
}

// Sign the transaction
const tx = JSON.parse(argv.tx),
signedTx = sign(tx, argv.privateKey);
var web3 = new Web3(argv.rpcEndpoint);

process.stdout.write(signedTx);
web3.eth.accounts.signTransaction(
JSON.parse(argv.tx),
argv.privateKey,
((error, result) => {
if (error) {
process.stdout.write('ERROR: ' + error.message || 'ERROR: An unknown error has occurred signing this transaction')
}
process.stdout.write(result.rawTransaction)
}));

break;
case 'recoverAddress':
if (!argv.message || !argv.signature) {
Expand Down Expand Up @@ -45,4 +51,4 @@ switch (argv._[0] || '') {
default:
process.exit(1);

}
}
Loading