web3.js plugin for Aurora NEAR engine
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/ :
Method | How to call | Comments | |
---|---|---|---|
web3_clientVersion | ✅ |
web3.aurora.web3.clientVersion()
|
Same as calling eth.getNodeInfo()
|
web3_sha3 | ✅ | web3.aurora.web3.sha3(value) |
It supposes to provide the same result as calling web3.utils.sha3
|
net_listening | ✅ | web3.aurora.net.isListening() |
|
net_peerCount | ✅ | web3.aurora.net.getPeerCount() |
|
net_version | ✅ | web3.aurora.net.getId() |
|
eth_accounts | ✅ | web3.aurora.eth.getAccounts() |
|
eth_blockNumber | ✅ | web3.aurora.eth.getBlockNumber() |
|
eth_call | ✅ | web3.aurora.eth.call({ |
|
eth_chainId | ✅ | web3.aurora.eth.getChainId() |
|
eth_coinbase | ✅ | web3.aurora.eth.getCoinbase() |
|
eth_compileLLL | ❌ | Unsupported | |
eth_compileSerpent | ❌ | Unsupported | |
eth_compileSolidity | ❌ | Unsupported | |
eth_estimateGas | ✅ | web3.aurora.eth.estimateGas(transaction) |
|
eth_gasPrice | ✅ | web3.aurora.eth.getGasPrice() |
|
eth_getBalance | ✅ | web3.aurora.eth.getBalance(address) |
|
eth_getBlockByHash | ✅ | web3.aurora.eth.getBlock(blockHash) |
|
eth_getBlockByNumber | ✅ | web3.aurora.eth.getBlock(blockNumber) |
|
eth_getBlockTransactionCountByHash | ✅ | web3.aurora.eth.getBlockTransactionCount(blockHash) |
|
eth_getBlockTransactionCountByNumber | ✅ | web3.aurora.eth.getBlockTransactionCount(blockNumber) |
|
eth_getCode | ✅ | web3.aurora.eth.getCode(address) |
|
eth_getCompilers | ✅ | web3.aurora.eth.getCompilers() |
|
eth_getFilterChanges | ✅ | web3.aurora.eth.getFilterChanges(filterId) |
|
eth_getFilterLogs | ✅ | web3.aurora.eth.getFilterLogs(filterId) |
|
eth_getLogs | ✅ | web3.aurora.eth.getPastLogs(filter) |
|
eth_getProof | ❌ | EIP-1186 | |
eth_getStorageAt | ✅ | web3.aurora.eth.getStorageAt(address, storageSlot) |
|
eth_getTransactionByBlockHashAndIndex | ✅ | web3.aurora.eth.getTransactionFromBlock(blockHash, transactionIndex) |
|
eth_getTransactionByBlockNumberAndIndex | ✅ | web3.aurora.eth.getTransactionFromBlock(blockNumber, transactionIndex) |
|
eth_getTransactionByHash | ✅ | web3.aurora.eth.getTransaction(transactionHash) |
|
eth_getTransactionCount | ✅ | web3.aurora.eth.getTransactionCount(address [, block]) |
|
eth_getTransactionReceipt | ✅ | web3.aurora.eth.getTransactionReceipt(transactionHash) |
|
eth_getUncleByBlockHashAndIndex | ✅ | web3.aurora.eth.getUncle(blockHash, uncleIndex) |
|
eth_getUncleByBlockNumberAndIndex | ✅ | web3.aurora.eth.getUncle(blockNumberOrTag, uncleIndex) |
|
eth_getUncleCountByBlockHash | ✅ | web3.aurora.eth.getBlockUncleCount(blockHash) |
|
eth_getUncleCountByBlockNumber | ✅ | web3.aurora.eth.getBlockUncleCount(blockNumber) |
|
eth_getWork | ❌ | Unsupported | |
eth_hashrate | ✅ | web3.aurora.eth.getHashRate() |
|
eth_mining | ✅ | web3.aurora.eth.isMining() |
|
eth_newBlockFilter | ✅ | web3.aurora.eth.newBlockFilter() |
|
eth_newFilter | ✅ | web3.aurora.eth.newFilter() |
|
eth_newPendingTransactionFilter | ✅ | web3.aurora.eth.newPendingTransactionFilter() |
|
eth_pendingTransactions | ✅ | web3.aurora.eth.getPendingTransactions() |
|
eth_protocolVersion | ✅ | web3.aurora.eth.getProtocolVersion() |
|
eth_sendRawTransaction | ✅ | web3.aurora.eth.sendSignedTransaction(tx) |
|
eth_sendTransaction | ❌ | Unsupported | |
eth_sign | ❌ | ||
eth_signTransaction | ❌ | Unsupported | |
eth_signTypedData | ❌ | Unsupported | |
eth_submitHashrate | ❌ | Unsupported | |
eth_submitWork | ❌ | Unsupported | |
eth_syncing | ✅ | web3.aurora.eth.isSyncing() |
|
eth_uninstallFilter | ✅ | web3.aurora.eth.uninstallFilter(filterId) |
|
db_getHex | ❌ | Deprecated | |
db_getString | ❌ | Deprecated | |
db_putHex | ❌ | Deprecated | |
db_putString | ❌ | Deprecated | |
shh_addToGroup | ❌ | Discontinued | |
shh_getFilterChanges | ❌ | Discontinued | |
shh_getMessages | ❌ | Discontinued | |
shh_hasIdentity | ❌ | Discontinued | |
shh_newFilter | ❌ | Discontinued | |
shh_newGroup | ❌ | Discontinued | |
shh_newIdentity | ❌ | Discontinued | |
shh_post | ❌ | Discontinued | |
shh_uninstallFilter | ❌ | Discontinued | |
shh_version | ❌ | Discontinued | |
txpool_content | ❌ | Unsupported | |
txpool_inspect | ❌ | Unsupported | |
txpool_status | ❌ | Unsupported | |
parity_pendingTransactions | ✅ | web3.aurora.parity.pendingTransactions() |
Parity extension |