Skip to content

FilOzone/foc-devnet-info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foc-devnet-info

Load and use your foc-devnet configuration in your dApps. This library reads the devnet-info.json file and provides everything you need to connect to your local Filecoin network.

Installation (no npm publish)

If this package isn’t published to npm, you can still use it locally.

Option A: Install from a local folder

npm install /absolute/path/to/foc-devnet-info

Option B: Install from a Git repo

npm install git+https://github.com/FilOzone/foc-devnet-info.git

Either way, you can keep the same import paths in your app:

import { loadDevnetInfo, toViemChain } from '@filozone/foc-devnet-info';

Quick Start

Load DevNet Info

import { loadDevnetInfo } from '@filozone/foc-devnet-info';

const devnetInfo = loadDevnetInfo();
// Uses default path: ~/.foc-devnet/state/latest/devnet-info.json

// Or provide a custom path
const devnetInfo = loadDevnetInfo('/path/to/devnet-info.json');

Get User Details

const user1 = devnetInfo.info.users[0];
console.log(user1.name);           // "USER_1"
console.log(user1.evm_addr);       // "0x47cc9101fd026fc112d7fadf6b3c9df5be7d4a8c"
console.log(user1.native_addr);    // "t410fi7gjcap5ajx4cewx7lpwwpe56w7h2sumb6jbvva"
console.log(user1.private_key_hex); // "0xf0ea8d631d31668a3b26999169037c0b75f505c675522d956e7cf114938d7f81"

Create a Viem Client

import { loadDevnetInfo, toViemChain } from '@filozone/foc-devnet-info';
import { createPublicClient, http } from 'viem';

const devnetInfo = loadDevnetInfo();
const chain = toViemChain(devnetInfo);

const client = createPublicClient({
  chain,
  transport: http(),
});

// Now use the client
const balance = await client.getBalance({
  address: devnetInfo.info.users[0].evm_addr,
});

Access Contract Addresses

const contracts = devnetInfo.info.contracts;
console.log(contracts.multicall3_addr);
console.log(contracts.fwss_service_proxy_addr);
console.log(contracts.pdp_verifier_proxy_addr);
// ... and more

Testing

Before running tests, make sure:

  1. The foc-devnet is running - The Lotus RPC endpoint must be accessible
  2. devnet-info.json exists - At ~/.foc-devnet/state/latest/devnet-info.json

Then run:

npm test

The test will:

  • ✓ Load the devnet configuration
  • ✓ Verify the devnet-info.json file exists
  • ✓ Check that the RPC endpoint is accessible
  • ✓ Query USER_1's balance on the network

Types

All types are exported and available for TypeScript:

import type {
  VersionedDevnetInfo,
  DevnetInfoV1,
  UserInfo,
  ContractsInfo,
  LotusInfo,
  LotusMinerInfo,
  CurioInfo,
  YugabyteInfo,
} from '@filozone/foc-devnet-info';

License

MIT

About

A TS library to help use foc-devnet

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published