send-ether-fix
A simple CLI tool for sending Ethereum ether using any of the following:
- A wallet's private key
- A keystore file
- An HD wallet mnemonic phrase
- A provider (node) wallet address
For the ERC20 token version of this package, check out send-tokens.
Contents
Installation
npm install -g send-ether-fix# or yarn global add send-ether-fix
Examples Nodejs
const toWallet = ;let x = ;console
Examples CLI
# Recipient of ether. May also be an ENS name. DST='0x0420DC92A955e3e139b52142f32Bd54C6D46c023'# Sending wallet's private key. PRIVATE_KEY='0x52c251b9e04740157471a724e9a3210b83fac5834b29c89d5bd57661bd2a7057'# Sending wallet's HD mnemonic. MNEMONIC='butter crepes sugar flour eggs milk ...' # Send 100.2 ether to and address, # on the mainnet, using a wallet's private key $ send-ether-fix --key $PRIVATE_KEY $DST 100.2 # Send 5.2 gwei (5.2e-9 ether) to an address, on ropsten, # using an HD wallet mnemonic $ send-ether-fix --network ropsten --mnemonic "$MNEMONIC" $DST 5.2 -d 9 # Send 10 wei (100e-18 ether) to an address, on the mainnet, # using a keystore file. $ send-ether-fix --keystore './path/to/keystore.json' --password 'secret' $DST 10 -d 0 # Send 1.5 ether to an address, on the provider's network, # using the provider's default wallet, and wait for 3 confirmations. $ send-ether-fix --provider 'http://localhost:8545' --confirmations 3 $DST 1.5
All Options
$ send-ether-fix --help
Usage: send-ether-fix [options] <to> <amount>
Options:
-v, --version output the version number
-d, --decimals <n> decimal places amount is expressed in (default: 18)
-k, --key <hex> sending wallet's private key
-f, --key-file <file> sending wallet's private key file
-s, --keystore-file <file> sending wallet's keystore file
--password <password> keystore file password
-m, --mnemonic <phrase> sending wallet's HD wallet phrase
--mnemonic-index <n> sending wallet's HD wallet account index (default: 0)
-a, --account <hex> sending wallet's account address (provider wallet)
-c, --confirmations <n> number of confirmations to wait for before returning (default: 0)
-p, --provider <uri> provider URI
-n, --network <name> network name
-G, --gas-price <gwei> explicit gas price, in gwei (e.g., 20)
-l, --log <file> append a JSON log to a file
--no-confirm bypass input confirmation
-h, --help output usage information
JSON Logs
If you pass the --log
option, a JSON object describing the transfer
will be appended to a file when the transaction is mined, one object per line.
Log Entries
Log entries follow this structure:
// Unique transfer ID to identify related logs. id: '88fdd8a4b8084c36' // UNIX time. time: 1532471209842 // Address of sender. from: '0x0420DC92A955e3e139b52142f32Bd54C6D46c023' // Address of recipient. to: '0x2621Ea417659Ad69BAE66AF05eBE5788e533E5e8' // Amount of ether sent (in weis). amount: '20' // Transaction ID of transfer. txId: '0xd9255f8365305ebffd77cb30d09f82745eaa232e42739f5fc2788fa46f1347e3' // Block number where the transfer was mined. block: 4912040 // Gas used. gas: 40120
ENS Names
Anywhere you can pass an address, you can also pass an ENS name, like
'ethereum.eth'
, and the it will automatically be resolved to a real
address.
ENS resolution only works on the mainnet, rinkeby, and ropsten, and the name must be fully registered with the ENS contract and a resolver.
Library Usage
The send-ether-fix
package can be used as a library through the sendEther()
function.
sendEther()
asynchronously resolves to a
transaction receipt
once the transaction has been mined (or confirmed, if the
confirmations
option is > 0).
sendEther() Examples
const sendEther = ;// Recipient of ether.const RECIPIENT = '0x0420DC92A955e3e139b52142f32Bd54C6D46c023'; // Sending wallet's private key.const PRIVATE_KEY = '0x52c251b9e04740157471a724e9a3210b83fac5834b29c89d5bd57661bd2a7057';// Send 100.5 ether to someone using a private key and wait for// it to be mined.let receipt = await ; // Sending wallet's mnemonic.const MNEMONIC = 'butter crepes sugar flour eggs milk ...';// Send 32 wei (32e-18) to someone using a (BIP39) mnemonic phrase// and wait for it to be mined and confirmed 3 times.receipt = await ; // Sending wallet's keystore file contents as a string.const KEYSTORE = '{...}';// Keystore password.const PASSWORD = 'secret';// Send 20.1 gwei (1e-9) to someone using a keystore file,// print the transaction ID when it's available, and wait for it to be mined.receipt = await ;
Full sendEther() Options
const sendEther = ;// Send AMOUNT ether to RECIPIENT.tx: Object = async ;
toWallet()
Another exposed library function is toWallet()
, which returns an address
& private key pair from a private key, mnemonic, or keystore. Below are the
full options.
const toWallet = ;// Convert a private key, mnemonic, or keystore to an address and private-key// pair object. Both fields will be a hex-encoded string.address: String key: String = ;