Skip to content
/ Anix Public
forked from evertonfraga/Anix

Minimal and flexible JSON-RPC wrapper

License

Notifications You must be signed in to change notification settings

Xalava/Anix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anix

NPM Package

Image description

Minimal (< 1 Kb), dependency-free and flexible JSON-RPC client library for Ethereum.

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  ♦   ♦   ♦   ♦
   ♦   ♦   ♦   ♦   ♦   ♦   ♦   ♦   ♦   ♦   ♦   ♦

Anix > await eth.blockNumber()
'0x12705de'

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.

About

Minimal and flexible JSON-RPC wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%