Skip to content

Mouradif/rpc-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rpc

rpc is a lightweight command-line tool for storing, listing, checking, and retrieving named RPC endpoints.

Demo of rpc CLI


Features

  • rpc --add <name>: Save a new RPC by name
  • rpc <name>: Print the saved RPC URL. If called in a non-tty (like $(rpc <name>), it will omit the trailing newline character)
  • rpc --list: Show a list of saved RPCs.
  • Fully local: all data saved in a plain text file at $XDG_CONFIG_HOME/rpc/list (or $HOME/.config/rpc/list if $XDG_CONFIG_HOME is not set)

Install

Built with Zig. You can build from source or download a binary from the releases section (coming soon).

git clone https://github.com/Mouradif/rpc-cli
cd rpc-cli
zig build --release=fast
cp zig-out/bin/rpc ~/.local/bin # Or any directory in your $PATH

Usage

$ rpc --add eth   # prompts for URL and saves it as "eth"
$ rpc eth         # prints the previously saved RPC URL with a trailing newline character
$ rpc --list      # shows list of all saved RPCs

File Format

Your saved RPCs are stored line-by-line in:

~/.config/rpc/list

Each line has the format:

name|url

Example:

mainnet|https://mainnet-url
sepolia|https://sepolia-url

Example with cast

Use rpc in shell scripts or with tools like cast:

$ cast chain-id -r $(rpc mainnet)

Contribute

Contributions are welcome! Here are some features I want to put in the roadmap

  • Add a --edit command to edit the list in $EDITOR (or vim)
  • Add a --check command that tries to fetch the chain ID or latest block number from the RPC to ensure it is up
  • Come up with other improvements

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages