Skip to content

Generate real Filecoin and Ethereum JSON-RPC method definitions with up-to-date parameters from live chain state.

License

Notifications You must be signed in to change notification settings

ChainSafe/filecoin-requests-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

filecoin-requests-builder

Generate real Filecoin and Ethereum JSON-RPC method definitions with up-to-date parameters from live chain state.

✨ Features

  • 🔁 Automatically queries chain state to populate dynamic parameters
  • 🔧 Allows manual override of parameters
  • 🧩 Supports both Filecoin and Ethereum RPC methods
  • 🧪 Suitable for use in benchmarks, simulations, or integration tests

🚀 Install

npm install filecoin-requests-builder

🛠 Usage

You can either automatically fetch context from an RPC endpoint, or manually provide parameters yourself.

Option 1: Use live chain data (recommended)

import { fetchRpcContext, buildRequests } from 'filecoin-requests-builder';

const rpcUrl = 'https://fil-rpc.url';
const context = await fetchRpcContext(rpcUrl);
const requests = buildRequests(context);

// Call any method
e.g. sendRpcRequest(rpcUrl, {
  name: 'eth_getBalance',
  params: requests['eth_getBalance'].params
});

Option 2: Provide your own context manually

import { buildRequests } from 'filecoin-requests-builder';

const context = {
  ethAddress: '0x1234...',
  ethZeroAddress: '0x0000000000000000000000000000000000000000',
  ethBlockHash: '0xabc...',
  ethTransactionHash: '0xdef...',
  filecoinAddress: 'f1xyz...',
  filecoinActorId: 'f01234',
  filecoinTipsetHeight: 123456,
  filecoinMinerId: 'f01234'
};

const requests = buildRequests(context);

📚 API

fetchRpcContext(rpcUrl: string): Promise<RpcContext>

Fetches current addresses, IDs, and block data to use in JSON-RPC method definitions.

buildRequests(context: RpcContext): RpcMethodMap

Returns an object where each key is a method name (e.g. eth_getBalance) and the value is:

{ params: any[] }

About

Generate real Filecoin and Ethereum JSON-RPC method definitions with up-to-date parameters from live chain state.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published