Gast is an open-source command-line transaction toolkit designed to streamline the management of Ethereum (including testnets and EVM compatible Layer 2s) transactions and gas prices. It provides some sets of commands for managing transactions (including creation, signing, and tracing).
Firstly, ensure you have Go language installed. To verify, run:
go version
If not installed, you can here: https://go.dev/dl/
After installing Go, run this command to install Gast:
go install github.com/Jesserc/gast@latest
Check if Gast is installed:
gast help
If the command is not recognized, you would have to add the Go Bin directory to your path.
export PATH=$PATH:$(go env GOPATH)/bin
Or manually paste it in your .bashrc
, .zshrc
file.
nano ~/.zshrc # add => export PATH=$PATH:$(go env GOPATH)/bin
# or
nano ~/.bashrc # add => export PATH=$PATH:$(go env GOPATH)/bin
To use Gast, run:
gast [command]
completion
: Generate the autocompletion script for the specified shell.gas-price
: Fetch the current gas price from specified Ethereum networks.help
: Help about any command.tx
: Manages Ethereum transactions, including creation, signing, and tracing.
-h, --help
: Help for Gast.
For more information about a command, use:
gast [command] --help
Manage Ethereum transactions with ease. The tx
command supports a variety of subcommands:
gast tx [sub-command] [flags]
create-contract
: Deploy Solidity contractcreate-raw
: Generate a raw, signed EIP-1559 transaction to propagate latersend-raw
: Propagate a raw, signed transaction. The nonce must not be usedsend-blob
: Create and send an EIP-4844 blob transactionget-blob
: Get blob transaction datasend
: Send EIP-1559 transactiontrace
: Retrieve and display the execution trace (path) of a given transaction hashsign-message
: Sign a given message with a private keyverify-sig
: Verify the signature of a signed message (can be created with the sign-message command)estimate-gas
: Estimate the gas required to execute a given transactionget-nonce
: Get the transaction count of an account
To fetch the current gas prices from specific Ethereum networks, use:
gast gas-price [flags]
Supported flags include:
--eth
: Use the default Ethereum RPC URL.--op
: Use the default Optimism RPC URL.--arb
: Use the default Arbitrum RPC URL.--base
: Use the default Base RPC URL.--linea
: Use the default Linea RPC URL.--zksync
: Use the default zkSync RPC URL.-u, --rpc-url string
: Specify a custom RPC URL for fetching the gas price.
To generate completions for zsh shell, run:
gast completion zsh # or use your shell
Save completion script to a completion file:
mkdir -p ~/.zsh/completion
nano ~/.zsh/completion/_gast # paste the completion script here
Open .zshrc to Include the Completion Directory:
nano ~/.zshrc
Add the following lines to set completions:
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit
compinit
Apply changes:
source ~/.zshrc
Here are some practical examples to help you get started with Gast. These commands demonstrate how to use Gast for managing Ethereum transactions and gas prices.
# Fetch current gas price for Ethereum network
gast gas-price --eth
# Fetch gas price from a custom RPC URL
gast gas-price --rpc-url https://forno.celo.org
# Deploy a Solidity contract
gast tx create-contract --rpc-url https://sepolia.drpc.org --private-key "2843e08c0fa87258545656e44955aa2c6ca2ebb92fa65507e4e5728570d36662" --gas-limit 1599000 -d contracts/CurrentYear.sol
# Create a raw, signed EIP-1559 transaction
gast tx create-raw --rpc-url "https://eth-sepolia.g.alchemy.com/v2/Of6ow3pvkFafGPn8Y2uk9vz4bSveZQxa" --to "0x4924Fb92285Cb10BC440E6fb4A53c2B94f2930c5" --private-key "2843e08c0fa87258545656e44955aa2c6ca2ebb92fa65507e4e5728570d36662" --gas-limit 21000 --wei 10000000000000
# Submit a raw, signed transaction to the Ethereum network
gast tx send-raw --raw-tx b87402f87183aa36a781d7843b9aca0084f702d4c28256ce944924fb92285cb10bc440e6fb4a53c2b94f2930c58398968080c080a081725247a454fc36e3ecd411ef6e7ddb89e668745fb2a5169ea08bfc4f5b617ba013cce55e74f620f15904e30a1c0f3e5dad22919e782468afe372d3bc6f5222b0 --rpc-url "https://eth-sepolia.g.alchemy.com/v2/Of6ow3pvkFafGPn8Y2uk9vz4bSveZQxa"
# Estimate gas for a transaction
gast tx estimate-gas --from 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --to 0xbe0eb53f46cd790cd13851d5eff43d12404d33e8 --rpc-url https://rpc.mevblocker.io --data 'Hello Ethereum!'
# Get the transaction count of an account
gast tx get-nonce --address 0x8741Fb04b7d8f5A01e0ec1D454602Bc08BDB0c8c --rpc-url https://sepolia.drpc.org
# Create and send an EIP-4844 blob transaction
gast tx send-blob --to 0x571B102323C3b8B8Afb30619Ac1d36d85359fb84 --rpc-url "https://rpc2.sepolia.org" --private-key "2843e08c0fa87258545656e44955aa2c6ca2ebb92fa65507e4e5728570d36662" --blob-data 'Hello Blobs!' --dir gast/blob-tx # dir to save blob tx result
# retrieve EIP-4844 blob transaction data
gast tx get-blob --id 8626178 --kzg-commitment 0xb28e4d255047f6e50b3d7548d37155b6e2289e82520aa6248d9fbe50e73b81d9f705cb3f2192d55caf54e26fb29c419a # `id` is the block root (32 bytes) or slot number of the blob tx and `kzg-commitment` is the kzg commitment (48 bytes) of the blob
# Sign a message with a private key
gast tx sign-message -m Jesserc -p "2843e08c0fa87258545656e44955aa2c6ca2ebb92fa65507e4e5728570d36662"
# Verify the signature of a signed message
gast tx verify-sig --sig 0x5e9faa36429804f79bd8ca495e21095f29f1038ec2b3f10788437a16d52f79682aca534e2b4ff0f426d6444555d807e6bc1c7c8a6b21aaaa4676d4f5e8d45b541b --address 0x571B102323C3b8B8Afb30619Ac1d36d85359fb84 --msg Jesserc
# Retrieve the execution trace of a transaction
gast tx trace --hash 0xee92800f24e23971c0ab031b30d60d6414e2255a308993d902604f4cfc1e4e7f -u https://rpc.builder0x69.io/
To run unit test:
go test -v ./... -short
To run integration test (connects to network):
go test -v ./... -run Integration
Good PRs or suggestions are welcomed.