SkillAgentSearch skills...

Ethutil

An Ethereum util, can transfer eth, check balance, call any contract function etc. All EVM-compatible chains are supported.

Install / Use

/learn @10gic/Ethutil
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

ethutil

An Ethereum util, can transfer eth, check balance, call any contract function etc. All EVM-compatible chains are supported.

You can also try another project foundry (cast) , which has very rich functionality. (When I created this project, the foundry project didn't exist yet.)

Documentation

An Ethereum util, can transfer eth, check balance, call any contract function etc. All EVM-compatible chains are supported.

Usage:
  ethutil [command]

Available Commands:
  balance                 Check eth balance for address
  transfer                Transfer native token
  call                    Invoke the (paid) contract method
  query                   Invoke the (constant) contract method
  deploy                  Deploy contract
  deploy-erc20            Deploy an ERC20 token
  drop-tx                 Drop pending tx for address
  4byte                   Get the function signatures for the given selector from https://openchain.xyz/signatures or https://www.4byte.directory
  encode-param            Encode input arguments, it's useful when you call contract's method manually
  gen-key                 Generate eth mnemonic words, private key, and its address
  dump-address            Dump address from mnemonics or private key or public key
  compute-contract-addr   Compute contract address before deployment
  build-raw-tx            Build raw transaction, the output can be used by rpc eth_sendRawTransaction
  broadcast-tx            Broadcast tx by rpc eth_sendRawTransaction
  decode-tx               Decode raw transaction
  code                    Get runtime bytecode of a contract on the blockchain, or EIP-7702 EOA code.
  erc20                   Call ERC20 contract, a helper for subcommand call/query
  keccak                  Compute keccak hash of data. If data is a existing file, compute the hash of the file content
  personal-sign           Create EIP191 personal sign
  eip712-sign             Create EIP712 sign
  aa-simple-account       AA (EIP4337) simple account, owned by an EOA account
  download-src            Download source code of contract from block explorer platform, eg. etherscan.
  eip7702-set-eoa-code    Set EOA account code, see EIP-7702. Just use 0x0000000000000000000000000000000000000000 when you want to clear the code.
  eip7702-sign-auth-tuple Sign EIP-7702 authorization tuple, see EIP-7702.
  public-rpc              Show public RPC endpoints for a chain
  recover-public-key      Recover public key and address from message hash and signature
  help                    Help about any command
  completion              Generate the autocompletion script for the specified shell

Flags:
      --chain string                      mainnet | sepolia | sokol | bsc. This parameter can be set as the chain ID, in this case the rpc comes from https://chainid.network/chains_mini.json (default "sepolia")
      --dry-run                           do not broadcast tx
      --gas-limit uint                    the gas limit
      --gas-price string                  the gas price, unit is gwei.
  -h, --help                              help for ethutil
      --max-fee-per-gas string            maximum fee per gas they are willing to pay total, unit is gwei. see eip1559
      --max-priority-fee-per-gas string   maximum fee per gas they are willing to give to miners, unit is gwei. see eip1559
      --node-url string                   the target connection node url, if this option specified, the --chain option is ignored
      --nonce int                         the nonce, -1 means check online (default -1)
  -k, --private-key string                the private key, eth would be send from this account
      --show-estimate-gas                 print estimate gas of tx
      --show-input-data                   print input data of tx
      --show-pre-hash                     print pre hash, the input of ecdsa sign
      --show-raw-tx                       print raw signed tx
      --terse                             produce terse output
      --tx-type string                    eip155 | eip1559, the type of tx your want to send (default "eip1559")

Use "ethutil [command] --help" for more information about a command.

Install

go install github.com/10gic/ethutil@latest

Usage Example

Check Balance (extremely fast for multiple addresses)

Check balance of an address:

$ ethutil --chain mainnet balance 0x79047aBf3af2a1061B108D71d6dc7BdB06474790
addr 0x79047aBf3af2a1061B108D71d6dc7BdB06474790, balance 231.905355677037965414 ether

Check balances of multiple addresses, it's really fast (only take about 10s for 10000 addresses):

$ ethutil --chain mainnet balance --input-file address.txt         # address.txt format: one address per line
addr 0x00000000219ab540356cbb839cbe05303d7705fa, balance 1.989730000000000005 ether
addr 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, balance 33.749145122485331533 ether
addr 0xbe0eb53f46cd790cd13851d5eff43d12404d33e8, balance 1 ether
addr 0x8315177ab297ba92a06054ce80a67ed4dbd7ed3a, balance 0 ether
......

Transfer ETH

Transfer 1 ETH to 0xB2aC853cF815B47903bc19BF4860540306F4f944:

$ ethutil --chain mainnet transfer 0xB2aC853cF815B47903bc19BF4860540306F4f944 1 --private-key 0xXXXX

Transfer all remaining ETH to 0xB2aC853cF815B47903bc19BF4860540306F4f944:

$ ethutil --chain mainnet transfer 0xB2aC853cF815B47903bc19BF4860540306F4f944 all --private-key 0xXXXX

Contract Interaction

Invokes the (paid) contract method:

$ ethutil --chain mainnet --private-key 0xXXXX call 0xdac17f958d2ee523a2206206994597c13d831ec7 'transfer(address, uint256)' 0x8F36975cdeA2e6E64f85719788C8EFBBe89DFBbb 1000000

Invokes the (paid) contract method with abi file:

$ ethutil --chain mainnet --private-key 0xXXXX call 0xdac17f958d2ee523a2206206994597c13d831ec7 --abi-file path/to/abi transfer 0x8F36975cdeA2e6E64f85719788C8EFBBe89DFBbb 1000000

Invokes the (constant) contract method:

$ ethutil --chain mainnet query 0xdac17f958d2ee523a2206206994597c13d831ec7 'balanceOf(address) returns (uint256)' 0x703662e526d2b71944fbfb9d87f61de3e0f0f290
ret0 = 1100000000000

Invokes the (constant) contract method with abi file:

$ ethutil --chain mainnet query 0xdac17f958d2ee523a2206206994597c13d831ec7 --abi-file path/to/abi balanceOf 0x703662e526d2b71944fbfb9d87f61de3e0f0f290

Deploy Contract

Deploy a contract:

$ ethutil --private-key 0xXXXX deploy --bin-file Contract1_sol_Contract1.bin

The binary file Contract1_sol_Contract1.bin can be generated by solcjs, for example:

$ solcjs --bin Contract1.sol      # generate Contract1_sol_Contract1.bin

Deploy A ERC20 Token

Deploy A ERC20 Token (use default setting: totalSupply = "10000000000000000000000000", name = "A Simple ERC20", symbol = "TEST", decimals = 18)

$ ethutil deploy-erc20

Drop Pending Tx

$ ethutil drop-tx --private-key 0xXXXX

Encode Param

An example:

$ ethutil encode-param 'transfer(address, uint256)' 0x8F36975cdeA2e6E64f85719788C8EFBBe89DFBbb 1000000
MethodID: 0xa9059cbb
[0]:  0x0000000000000000000000008f36975cdea2e6e64f85719788c8efbbe89dfbbb
[1]:  0x00000000000000000000000000000000000000000000000000000000000f4240
encoded parameters (input data) = 0xa9059cbb0000000000000000000000008f36975cdea2e6e64f85719788c8efbbe89dfbbb00000000000000000000000000000000000000000000000000000000000f4240

Another example:

$ ethutil encode-param 'swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline)' 12939945098273591402279 '[0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, 0x9Ed8e7C9604790F7Ec589F99b94361d8AAB64E5E]' 0x95206727FA3DD2FA32cd0BfE1fd40736B525CF11 1615952806
MethodID: 0x7ff36ab5
[0]:  0x0000000000000000000000000000000000000000000002bd79cff41cc68c1f27
[1]:  0x0000000000000000000000000000000000000000000000000000000000000080
[2]:  0x00000000000000000000000095206727fa3dd2fa32cd0bfe1fd40736b525cf11
[3]:  0x0000000000000000000000000000000000000000000000000000000060517ba6
[4]:  0x0000000000000000000000000000000000000000000000000000000000000002
[5]:  0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
[6]:  0x0000000000000000000000009ed8e7c9604790f7ec589f99b94361d8aab64e5e
encoded parameters (input data) = 0x7ff36ab50000000000000000000000000000000000000000000002bd79cff41cc68c1f27000000000000000000000000000000000000000000000000000000000000008000000000000000000000000095206727fa3dd2fa32cd0bfe1fd40736b525cf110000000000000000000000000000000000000000000000000000000060517ba60000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009ed8e7c9604790f7ec589f99b94361d8aab64e5e

Only encode arguments (without function selector):

$ ethutil encode-param '(address, uint256)' 0x8F36975cdeA2e6E64f85719788C8EFBBe89DFBbb 1000000
[0]:  0x0000000000000000000000008f36975cdea2e6e64f85719788c8efbbe89dfbbb
[1]:  0x00000000000000000000000000000000000000000000000000000000000f4240
encoded parameters (input data) = 0x0000000000000000000000008f36975cdea2e6e64f85719788c8efbbe89dfbbb00000000000000000000000000000000000000000000000000000000000f4240

Generate New Private Key

Generate mnemonic words and private key:

$ ethutil gen-key
mnemonic: obvious element orbit option muffin crop abuse duck general mule satoshi doll
private key: 0x836263588c9ea3ffa2a73b71a32d4eb886779d1e0e25f6324c582d2f1008d57f
public key: 0x04049817a72deed750a27a7abc772169378f1547133861d564eba86561a45f861658bcf9ba9cd1be852df8e1c2df76492402c665b9644fb2a37b29644ac17c0d45
addr: 0x2Ed852F7F064E56aa60fDA0a703ed4A7DCC5F9fb

Generate multiple keys:

$ ethutil --terse gen-key -n 10
0x4a7a7070d616c70ca7caa5e34dfa944f983d530be4831e6e0086a781a679c601 0x356EC6F0b43bdEB18C291D5e629c1585c3c0BA73
0x692d3eb6ea9df4fb67745b024aa08b6c3f0
View on GitHub
GitHub Stars48
CategoryCustomer
Updated4mo ago
Forks26

Languages

Go

Security Score

87/100

Audited on Nov 20, 2025

No findings