ethers.js/docs.wrm/cli/ethers-script.txt

20 lines
952 B
Plaintext
Raw Normal View History

2020-01-10 09:01:00 +03:00
# Get the formatted balance of an account
/home/ethers> ethers --network ropsten --account wallet.json eval 'accounts[0].getBalance().then(b => formatEther(b))'
3.141592653589793238
# Get the current block number
/home/ethers> ethers --network rinkeby eval "provider.getBlockNumber()"
5761009
# Convert a Solidity signature to JSON
/home/ethers> ethers eval 'utils.Fragment.from("function balanceOf(address owner) view returns (uint)").format("json")'
{"type":"function","name":"balanceOf","constant":true,"stateMutability":"view","payble":false,"inputs":[{"type":"address","name":"owner"}],"ouputs":[{"type":"uint256"}]}
# Compute a topic hash
/home/ricmoo> ethers eval 'id("Transfer(address,address,uint256")'
0xd99659a21de82e379975ce8df556f939a4ccb95e92144f38bb0dd35730ffcdd5
# Create a random mnemonic
/home/ricmoo> ethers eval 'Wallet.createRandom().mnemonic'
useful pond inch knock ritual matrix giggle attend dilemma convince coach amazing