anix-js
v0.0.2
Published
Minimal and flexible JSON-RPC wrapper for Ethereum
Downloads
1
Maintainers
Readme
Anix
The goal is to make it easy to work with RPC endpoints.
This library uses JavaScript Proxy object to allow arbitrary prototype method calls, the API offers an intuitive translation to the raw RPC methods, where eth_getLogs
becomes eth.getLogs()
, and so on.
Installation
$ npm i --save-dev anix-js
Basic usage:
main.mjs:
import {Anix} from 'anix-js'
const eth = new Anix('eth', <YOUR HTTP RPC ENDPOINT>)
console.dir(await eth.getBlockByNumber('latest', false))
$ node main.mjs
- or -
$ bun run main.mjs
Can be used for arbitrary/custom RPC methods:
import {Anix} from 'anix-js'
const eth = new Anix('eth', <YOUR HTTP RPC ENDPOINT>)
await eth.sendBundle({…})
Read-Eval-Print-Loop
Anix has a built-in REPL script, making it easy to prototype.
$ npx anix-js http://my-rpc-url.xyz
Welcome to Anix 🪷⚘
> eth.getBlockByNumber('latest', false)
> {…}
Benefits of using Anix:
- Works with any set of custom RPC methods, because of its native proxy object.
- It resembles the Geth console JavaScript APIs.
- It's incredibly portable, with a minimal footprint (less than 1kb minified).
- It uses the native
fetch
method, implemented on top of Undici. - No dependencies attached: Anix is not prone to supply-chain attacks.
Check the examples directory for boilerplate code.
Questions?
Ping me on twitter.