1

I have an air-gapped machine with Ubuntu Server. Is there any command line tool which I can quickly download to sign offline transactions? Something like:

sign-tx private_key_file nonce=10 gasPrice=... gasLimit=... to=... value=... data=... chainId=1

This would output the signed transaction in hex.

2 Answers 2

2

For the sake of convenience, I've published a tool using ethereumjs-tx to sign a transaction from the terminal. It works as follows:

# install it
npm i -g ethereum-offline-signer

# sign a transaction
eth-sign NONCE VALUE FROM_KEY [TO_ADDRESS] [GAS_PRICE] [GAS_LIMIT] [DATA] [CHAIN_ID]

With the arguments formatted as follow:

- NONCE      : an int (ex: 7)
- VALUE      : a float in ether (ex: 0.01)
- FROM_KEY   : a 256-bit hex (ex: 0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658)*
- TO_ADDRESS : optionally a hex address (ex: 0xC08B5542D177ac6686946920409741463a15dDdB)
- GAS_PRICE  : optionally a float in gwei (ex: 10)
- GAS_LIMIT  : optionally a float in gas (ex: 50000)
- DATA       : optionally a hex (ex: 0x01020304)
- CHAIN_ID   : optionally an in (ex: 1)

Here is its repository.

1

https://github.com/ethereumjs/ethereumjs-tx isn't a binary, but it's an easy-to-use node module available on npm.

npm install ethereumjs-tx

copy/paste the example code (with your modifications) into a node file, and have it print out the signed transaction.

signed.js

const EthereumTx = require('ethereumjs-tx')
const privateKey = Buffer.from('e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', 'hex')

const tx = new EthereumTx({
  nonce: '0x00',
  gasPrice: '0x09184e72a000', 
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000', 
  value: '0x00', 
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
  // EIP 155 chainId - mainnet: 1, ropsten: 3
  chainId: 3
})

tx.sign(privateKey)

console.log(tx.serialize())

node ./signed.js

1
  • Thanks, I've published a command-line tool for convenience as explained below.
    – MaiaVictor
    Commented Feb 21, 2019 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.