0.7.0 • Published 10 years ago
huff v0.7.0
huff
Commandline utility for ethereum. For convenience.
- Create, Mine and Reset private network.
- Keystore / Account tools.
- Transferring ether between accounts.
- Deploying contracts.
- Calling and transacting with contracts.
- Watching contracts
- Scripting
npm install -g huff
huff -hMade for osx/linux, your paths may differ
Create, Mine and Reset private network.
huff --reset
huff --reset [--datadir <alternative>]- Destroys the network in
$HOME/.huff/*or<alternative> - Recreates it, prompting for new etherbase account passphrase
- Generates
genesis.jsonfile.
huff --mine- Start mining the new network
- Creates
$HOME/.huff/geth.ipcfor attach
Keystore / Account tools.
huff --create-account- Creates a new account in the
datadir/keystore - Prompts for a passphrase for the new account
- Same as
geth --datadir ~/.huff/ account new - BUT: Adding accounts using geth will put the account sequences out of order
huff --list-accounts- List all accounts in
datadir/keystore - Listing includes balance in wei
huff --show-key <account>
huff --show-key 0
huff --show-key c10d9bbb5c9481860997e8dc5c6ada6e0ccd6f61- Show account's privateKey
huff --balance 0
huff --balance 9372fbb45a307c70f874f48a0668b512ed1ae64d- Show accounts balance in wei
Transferring ether between accounts.
huff --transfer 20 --to 2- Transfers 20 ether from
account[0]toaccount[2] - Prompts for passphrase for
account[0] - Displays transaction receipt
huff --transfer 10 \
--sender 9372fbb45a307c70f874f48a0668b512ed1ae64d \
--to 02a82e3e3fb4e2afb01971556373fa0e03898c79- Transfers 10 ether from sender address
- Prompts for passphrase of
9372fbb45a307c70f874f48a0668b512ed1ae64daccount
huff --transfer 10000000 --wei --sender 1 --to 0- Transfer unit as wei instead of ether
Deploying contracts
huff --deploy example/greeter.sol -p 'hello world!' [--gas 1000000]- Deploys contract from source in
example/greeter.sol - Constructor param as 'hello world'
- Writes deployment state files into
example/greeter.sol.deployed/* - You may want to
.gitignore *.deployed
huff --sender 2 --deploy example/imagine.sol -p 'all the' -p people- Supports more than one constructor parameter
huff --deploy example/greeter.sol -p 'hello africa!' --tag africa
huff --deploy example/greeter.sol -p 'hello asia!' --tag asia- Use optional
--tagto deploy multiple instances of the same contract. - Separate state files are created in
example/greeter.sol.deployed/* - The tag is used to distinguish between them in
--connectand--send(see below)
huff --compile example/greeter.sol- A variation on
--deploythat only performs the compile step - Stores subset of state files in
example/greeter.sol.deployed/(abi,code)
Calling and transacting with contracts
huff --connect example/greeter.sol --tag africa --send greet- Runs the
greet()method on the previously compiled contract - Uses the utility files (as deployed) from
example/greeter.sol.deployed/latest/*for ABI and Address - Displays the result to console
huff --connect example/greeter.sol --send echo -p 'arg1' -p 'arg2'- Runs
echo()with two arguments
huff --connect example/greeter.sol --send kill- Sends transaction to the
kill()method
huff --connect token.sol --send balanceOf -p 0x9372fbb45a307c70f874f48a0668b512ed1ae64d- Precede address with '0x' when passing as parameters
huff --compile contract.sol
huff --connect contract.sol --address 0x8ca785e0bea58aa09e88bc3411e648f5aff636bc --send method- Uses the compile (without deploy) option to generate the necessary abi utility file
- Then connects to an existing instance of that contact at the specified address
Watching contracts
huff --watch example/greeter.sol
# second console
huff --connect example/greeter.sol --send update -p 'hello world'- The first starts watching the contract for events.
- The second calls
update('hello world')which emits an event
Scripting
eg.
# deploy the parent contract
huff --pass z --deploy example/parent.sol
# spawn a child through it and use --json pointer to only
# print that part of the transaction reciept containing
# the new child's address
CHILD_ADDRESS=`huff --pass z --connect example/parent.sol --send spawnChild -p 'Child Name' --json /logs/0/args/child`
# compile but don't deploy the child
# (for abi written into example/child.sol.deployed/..
huff --compile example/child.sol
# get childs name
huff --connect example/child.sol --address $CHILD_ADDRESS --send nameTODO
- pop archive on kill()