Skip to content

gskapka/etheroff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

😻 Etheroff

A simple CLI for offline signing of ethereum transactions. It can also generate random ethereum private-keys.

 

📃 Build Instructions

1) Clone the repo:

❍ git clone https://github.com/gskapka/etheroff.git

2) Enter app dir and build it:

❍ cd etheroff && cargo b --release

3) You'll find the etheroff binary in:

❍ cd ./target/release

 

🔧 Usage Instructions

NOTE: This tool requires you have a gpg encrypted ethereum private key in hex format. There is a sample private key in the ./example directory which is symmetrically encrypted with the password etheroff for you to use to experiment with the tool!

To see the full usage instructions, run the binary with the help flag (etheroff --help):

❍ Etheroff ❍

    Copyright: Greg Kapka 2020
    Questions: [email protected]

❍ Info ❍

A simple CLI for offline signing of ethereum transactions.

❍ Usage ❍

Usage:  etheroff [--help]
        etheroff version
        etheroff generateRandom
        etheroff [--keyfile=<path>]
        etheroff signTransaction <to> <value> <nonce> [--gasLimit=<uint>] [--gasPrice=<uint>] [--data=<bytes>] [--chainId=<uint>] [--keyfile=<path>] [--logLevel=<string>]

Commands:

        version                ❍ Show version info.
        generateRandom         ❍ Generate random ETH private key & address.
        signTransaction        ❍ Sign an ethereum transaction.
        <to>                   ❍ Ethereum address to send the transaction to.
        <nonce>                ❍ The nonce to be used for the ethereum transaction.
        <value>                ❍ How much ether to send (in Wei!)
        <no-command>           ❍ Run the interactive Q&A version of this tool.

Options:

        --help                 ❍ Show this message.
        --keyfile=<path>       ❍ Path to GPG-encrypted ETH private key in hex format. [default: ./pk.gpg]
        --chainId=<uint>       ❍ The integer used to identify which chain to sign a transaction for.  [default: 1]
        --data=<bytes>         ❍ Any calldata required for the transaction, in hex format. [default: 0x]
        --gasLimit=<uint>      ❍ The gas limit for the ETH transaction. [default: 21000]
        --gasPrice=<uint>      ❍ The gas price for the ETH transaction. [default: 20000000000]
        --logLevel=<level>     ❍ Define the level of logging in the tool's output as one of: `none`, `info`, `debug`,
                                 `trace` or `error`. [default: none]

 

👏 Interactive Example:

Once you've built the tool, if you run the binary with NO commands (etheroff) you'll start the interactive version of the tool which walks you though each required part of an ethereum transaction, step-by-step:

❍ Etheroff - An ethereum offline transaction signer!
❍ Decrypting ethereum private key...
❍ Please enter the ethereum address to send to:
0xfEDFe2616EB3661CB8FEd2782F5F0cC91D59DCaC
✔ ETH address: 0xfedf…dcac
❍ Please enter the amount of ethereum to send (in ETH):
1.23
✔ Amount: 1.23 Ξ
❍ Please enter the nonce for the transaction:
1337
✔ Nonce: 1337
❍ Please enter the gas limit for the transaction:
21000
✔ Gas limit: 21000
❍ Please enter the gas price for the transaction (in GWEI):
60
✔ Gas price: 60 GWei
❍ Please select which network to use:
1 - Mainnet
2 - Kovan
3 - Goerli
4 - Ropsten
5 - Rinkeby
1
✔ Mainnet
❍ Please enter any calldata you want included (or leave blank for none!):

✔ ETH calldata: 0x

❍ Transaction details:
To:         0xfedf…dcac
Amount:     1.23 Ξ (1230000000000000000 Wei)
Nonce:      1337
Gas limit:  21000
Gas price:  60 GWei (60000000000 Wei)
Network:    Mainnet
Calldata:   0x
Total cost: 1 Ξ (1231260000000000000 Wei)

❍ Sign transaction? (y/n)
y
f86e820539850df847580082520894fedfe2616eb3661cb8fed2782f5f0cc91d59dcac881111d67bb1bb00008026a09d76015c4eda9937b84c0e02045bbeedf2498c24e8a1f4a04e8c9e5208de5078a04a97a0e04a20161c32b7e99b1e5a9af309e95a2988edeca6b39401d2435949e2

 

💻 Programmatic Example

You'll find a sample script in the ./example/ directory. Run it to see the tool in action:

11:18:23 [ INFO] ✔ Logger initialized successfully!
11:18:23 [ INFO] ✔ Signing transaction...
11:18:23 [ INFO] ✔ Maybe getting ETH private key & adding to state...
11:18:23 [ INFO] ✔ Checking ETH private keyfile exists...
11:18:23 [ INFO] ✔ Key file found @ ./example-private-key.gpg!
11:18:23 [ INFO] ✔ Decrypting private key...
11:18:26 [ INFO] ✔ Keyfile decrypted!
11:18:26 [ INFO] ✔ Creating Eth private key from hex...
11:18:26 [ INFO] ✔ ETH address: 0xd4f003e122e94982164f3d63ff68467e5c676e9e
11:18:26 [ INFO] ✔ Signing ETH transaction...
11:18:26 [ INFO] ✔ To: 0xfedf…dcac
11:18:26 [ INFO] ✔ On Ropsten Testnet
11:18:26 [ INFO] ✔ Using nonce: 1337
11:18:26 [ INFO] ✔ For amount: 1 Wei
11:18:26 [ INFO] ✔ With gas limit of: 30,000
11:18:26 [ INFO] ✔ And a gas price of: 60,000,000,000 Wei
11:18:26 [ INFO] ✔ With calldata: 0x0decaf
11:18:26 [ INFO] ✔ For a total price of : 0.001800000000000001 ETH
f869820539850df847580082753094fedfe2616eb3661cb8fed2782f5f0cc91d59dcac01830decaf2aa0c8a9434fa0775488d27f5395bcd4e1180b0b67800d58bc3a69f1e9071e45d3eba06084d3d8e723188c441403e0ecd6d7cd894346730a28d557eda393fc2eb0fda3

 

:shipit: Generating a random ETH address:

After building the tool, simply call it like so:

./etheroff generateRandom
{
  "eth_address": "0xc1eef08242d7da6bd4f5887ef38e37dc2c0d9110",
  "private_key": "0xd3df92df1f2445f9dd6e90464ebd51aa1e10c78a81998258bbfd297614e3c011"
}

NOTE: The above example has logging turned on. The tool will default to no logging and so only the final signed transaction will be outputted to stdout. Perfect for programmatic use-cases.

About

An offline ethereum transaction signer.

Resources

Stars

Watchers

Forks