npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@con3x/web3-plugin-aurora

v2.0.0

Published

web3.js plugin for Aurora Engine that is an EVM running atop NEAR protocol

Downloads

16

Readme

web3.js plugin for Aurora NEAR engine

Dependency Status

This is an npm package containing a web3.js plugin for Aurora NEAR engine.

Aurora is an EVM-compatible blockchain built as a smart contract atop NEAR blockchain. This plugin would leverage Aurora custom RPC methods. And it also do not display the unsupported methods. The Aurora supported RPC methods are listed at: https://doc.aurora.dev/evm/rpc/. And the most updated version is at: https://github.com/aurora-is-near/relayer2-public?tab=readme-ov-file#json-rpc-methods.

Plugin usage by users

At your typescript project first run: yarn add web3 @con3x/web3-plugin-aurora

And here is how to use the plugin:

import { Web3 } from 'web3';
import { AuroraPlugin } from '@con3x/web3-plugin-aurora';

async function aurora() {
  const web3 = new Web3('https://mainnet.aurora.dev');
  web3.registerPlugin(new AuroraPlugin(web3.provider));

  const blockNumber = await web3.aurora.eth.getBlockNumber();
  console.log('aurora blockNumber', blockNumber);

  const parityPendingTransactions =
    await web3.aurora.parity.pendingTransactions();
  console.log('aurora parity_pendingTransactions', parityPendingTransactions);
}

aurora();

You can play with the npm package online at: https://codesandbox.io/p/devbox/testing-web3-plugin-aurora-v7249s?file=%2Findex.js

Supported RPC Methods

Here are all RPC methods and how to call them using the plugin. The original table of RPC methods is from: https://doc.aurora.dev/evm/rpc/ :

Project progress:

NEAR Aurora Plugin

Create NEAR Aurora Plugin and publish it to the npm registry

The web3.js plugin for NEAR Aurora has been publish to
https://www.npmjs.com/package/@con3x/web3-plugin-aurora and it is useable inside this example playground: https://codesandbox.io/p/sandbox/misty-leftpad-v7249s?file=%2Findex.js. Additionally, some tests has been written to test some of the basic functionality.

web3.aurora is also accessible as web3.near.aurora

Aurora plugin could be used also as web3.near.aurora.

const web3 = new Web3("https://mainnet.aurora.dev");

const nearPlugin = new NearPlugin();
// registering the NearPlugin has to be done before registering the AuroraPlugin
// this will allow the provider to be passed from the Web3 instance to NearPlugin to AuroraPlugin
web3.registerPlugin(nearPlugin);
nearPlugin.registerPlugin(new AuroraPlugin());

const result = await web3.near.aurora.eth.getBlockNumber();

Enable all Ethereum RPC methods on AuroraPlugin

Now all Ethereum RPC methods are callable on web3.aurora.eth (and on web3.near.aurora.eth as a consequence). Additionally, all not-supported methods are not exposed as callable methods.

Support all RPC methods on AuroraPlugin organized in namespaces

NEAR Plugin

There is a web3.js plugin for the NEAR protocol. Check its repository at: https://github.com/con3x/web3-plugin-near

Running Tests

Testing AuroraPlugin

Executing yarn test aurora.test.ts would give something like:

 PASS  test/aurora.test.ts (42.118 s)
  AuroraPlugin Tests
    AuroraPlugin can call `web3` endpoints
      ✓ should be able to call `web3_clientVersion` (4264 ms)
      ✓ should be able to call `web3_sha3` (691 ms)
    AuroraPlugin can call `net` RPC endpoints
      ✓ should be able to call `net_listening` method (669 ms)
      ✓ should be able to call `net_peerCount` method (685 ms)
      ✓ should be able to call `net_version` method (670 ms)
    AuroraPlugin can call Ethereum standard RPC endpoints
      ✓ should be able to call `eth_accounts` method with expected param (1315 ms)
      ✓ should be able to call `eth_blockNumber` method with expected param (734 ms)
      ✓ should be able to call `eth_call` method with expected params (700 ms)
      ✓ should be able to call `eth_chainId` method with expected param (688 ms)
      ✓ should be able to call `eth_coinbase` method with expected param (684 ms)
      ✓ should be able to call `eth_estimateGas` method with expected param (1690 ms)
      ✓ should be able to call `eth_gasPrice` method with expected param (748 ms)
      ✓ should be able to call `eth_getBalance` method with expected param (692 ms)
      ✓ should be able to call `eth_getBlockByHash` method with expected param (3718 ms)
      ✓ should be able to call `eth_getBlockByNumber` method with expected param (1515 ms)
      ✓ should be able to call `eth_getBlockTransactionCountByHash` method with expected param (695 ms)
      ✓ should be able to call `eth_getBlockTransactionCountByNumber` method with expected param (706 ms)
      ✓ should be able to call `eth_getCode` (777 ms)
      ✓ should be able to call `eth_getCompilers` (1710 ms)
      ✓ should be able to call `eth_getFilterChanges` (1989 ms)
      ✓ should be able to call `eth_getFilterLogs` (1354 ms)
      ✓ should be able to call `eth_getLogs` (694 ms)
      ✓ should be able to call `eth_newFilter` (1343 ms)
      ✓ should be able to call `eth_protocolVersion` (676 ms)
      ✓ should be able to call `eth_syncing` (625 ms)
      ✓ should be able to call `eth_uninstallFilter` (3813 ms)
      ✓ should be able to call `eth_gasPrice` (714 ms)
      ✓ should be able to call `eth_coinbase` (745 ms)
      ✓ should be able to call `eth_getBalance` (2826 ms)
      ✓ should be able to call `eth_getCompilers` (660 ms)
      ✓ should calling `eth_getProof` throws (1 ms)
      ✓ should calling `eth_getWork` throws (1 ms)
      ✓ should have the rest of the methods at web3.aurora.eth all available (6 ms)
      ✓ should have the unavailable  methods at web3.aurora.eth as undefined (2 ms)
    AuroraPlugin can call `parity` endpoints
      ✓ should be able to call `parity_pendingTransactions` (1857 ms)
Test Suites: 1 passed, 1 total
Tests:       3 skipped, 35 passed, 38 total
Snapshots:   0 total
Time:        42.151 s

Executing yarn test near.aurora.test.ts would give something like:

 PASS  test/near.aurora.test.ts
  web3.near.aurora Tests
    ✓ should have `web3.near.aurora` setup (1 ms)
    ✓ should call `getBlockNumber` method on `web3.near.aurora.eth` (395 ms)

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        2.658 s, estimated 3 s

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

And for your proposed changes, please make sure to add and/or update tests as needed.