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.
If this package isn’t published to npm, you can still use it locally.
npm install /absolute/path/to/foc-devnet-infonpm install git+https://github.com/FilOzone/foc-devnet-info.gitEither way, you can keep the same import paths in your app:
import { loadDevnetInfo, toViemChain } from '@filozone/foc-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');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"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,
});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 moreBefore running tests, make sure:
- The foc-devnet is running - The Lotus RPC endpoint must be accessible
- devnet-info.json exists - At
~/.foc-devnet/state/latest/devnet-info.json
Then run:
npm testThe 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
All types are exported and available for TypeScript:
import type {
VersionedDevnetInfo,
DevnetInfoV1,
UserInfo,
ContractsInfo,
LotusInfo,
LotusMinerInfo,
CurioInfo,
YugabyteInfo,
} from '@filozone/foc-devnet-info';MIT