New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@chainsafe/filecoin-requests-builder

Package Overview
Dependencies
Maintainers
6
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chainsafe/filecoin-requests-builder

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

latest
npmnpm
Version
0.1.1
Version published
Weekly downloads
0
-100%
Maintainers
6
Weekly downloads
 
Created
Source

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.

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
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: '0x1234abcd...',
  ethZeroAddress: '0x0000000000000000000000000000000000000000',
  ethBlockHash: '0xabcde123...',
  ethTransactionHash: '0xdef456...',
  ethBlockNumber: '0x1a', // в hex-формате
  filecoinAddress: 'f1xyzabcd...',
  filecoinActorId: 'f01234',
  filecoinTipsetHeight: 123456,
  filecoinTipsetKey: [{ '/': 'bafykeyexample...' }],
  filecoinMessageCid: { '/': 'bafymsgcidexample...' },
  filecoinMinerId: 'f01234',
  filecoinMultisigAddress: 'f024757',
  ethContractAddress: '0xcontractabcd...',
  ethContractCallData: '0xcalldataabcd...',
};

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[] }

FAQs

Package last updated on 24 Jul 2025

Related posts