Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/draganm/rpcrequest
https://github.com/draganm/rpcrequest
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/draganm/rpcrequest
- Owner: draganm
- License: mit
- Created: 2024-03-28T12:37:30.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-01T21:31:52.000Z (9 months ago)
- Last Synced: 2024-11-06T09:19:55.880Z (about 2 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RPCRequest
RPCRequest is a versatile command-line utility designed for executing JSON-RPC (Remote Procedure Call) requests.
While it's tailored for seamless interaction with Ethereum RPC endpoints, its flexible design makes it suitable for a wide range of JSON-RPC based services.## Features
- **Ethereum RPC Support:** Optimized for Ethereum, facilitating direct command-line interactions with Ethereum nodes.
- **Broad JSON-RPC Compatibility:** Use it with any JSON-RPC service, not just Ethereum Nodes.
- **Environment Variable & Command Line URL Configuration:** Specify your RPC node URL through an environment variable or directly as a command-line argument.
- **Basic Auth Support:** Easily pass basic authentication credentials within the URL for secure endpoints.
- **Flexible Parameter Typing:** Convert string arguments to booleans, integers, or hex-encoded strings to meet various parameter requirements.## Getting Started
### Installation
#### Using Homebrew
```bash
brew install draganm/tools/rpcrequest
```#### Using `go install`
```bash
go install github.com/draganm/rpcrequest
```### Usage
RPCRequest accepts the JSON-RPC method name and parameters as command-line arguments.
The first argument should always be the method name, followed by each parameter as a separate argument.#### Example Command
```bash
rpcrequest --node-url https://my-node/path eth_getBlockByNumber asHex:12345 bool:true
```### Specifying the RPC Node
You can specify the RPC node URL in two ways:
1. **Environment Variable:** Set the `NODE_URL` environment variable with your RPC node URL.
2. **Command-Line Flag:** Use the `--node-url=` flag to provide the URL directly in your command.### Authentication
If the RPC endpoint requires basic authentication, include the credentials directly in the URL as follows:
```url
https://username:password@hostname/path
```### Converting to JSON Types
RPCRequest can automatically convert string arguments into the required JSON types. Use the following prefixes to indicate the type:
- `bool:` Converts the following value to a boolean (`true` or `false`).
- `int:` Converts the following value to an integer.
- `asHex:` Converts an integer value into a hex-encoded string prefixed with `0x`. This is particularly useful for Ethereum RPC parameters like block numbers.
- `json:` Converts a JSON string into a JSON value. This is useful when RPC parameter is a data structure.## Contributing
Contributions are welcome, send your issues and PRs to this repo.
## License
[MIT](LICENCE) - Copyright Dragan Milic and contributors.