{"id":26569865,"url":"https://github.com/checkernetwork/index-provider-peer-id","last_synced_at":"2026-01-04T19:06:58.425Z","repository":{"id":282401570,"uuid":"948454247","full_name":"CheckerNetwork/index-provider-peer-id","owner":"CheckerNetwork","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-14T11:59:52.000Z","size":35,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T12:33:59.703Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CheckerNetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-14T11:15:26.000Z","updated_at":"2025-03-14T11:17:53.000Z","dependencies_parsed_at":"2025-03-14T12:44:05.645Z","dependency_job_id":null,"html_url":"https://github.com/CheckerNetwork/index-provider-peer-id","commit_stats":null,"previous_names":["checkernetwork/index-provider-peer-id"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CheckerNetwork%2Findex-provider-peer-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CheckerNetwork%2Findex-provider-peer-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CheckerNetwork%2Findex-provider-peer-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CheckerNetwork%2Findex-provider-peer-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CheckerNetwork","download_url":"https://codeload.github.com/CheckerNetwork/index-provider-peer-id/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245026004,"owners_count":20549068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-22T21:39:55.925Z","updated_at":"2026-01-04T19:06:58.419Z","avatar_url":"https://github.com/CheckerNetwork.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# index-provider-peer-id\n\nFunctionality for fetching index provider peer IDs for a minder id on the Filecoin network.\n\n## Usage\n\n### Getting a Miner's PeerId\n\nThe library provides a function to retrieve a miner's PeerId by querying both the Filecoin smart\ncontract and Filecoin MinerInfo state. It returns the PeerID found in the smart contract, falling\nback to the PeerID found in MinerInfo state.\n\nThe function prioritizes the smart contract result. If the smart contract doesn't return a valid\nPeerId, it falls back to the result from FilecoinMinerInfo. If both methods fail, an error is thrown\nwith details about the failure.\n\n```js\nimport {\n  getIndexProviderPeerId,\n  MINER_TO_PEERID_CONTRACT_ADDRESS,\n  MINER_TO_PEERID_CONTRACT_ABI,\n} from '@filecoin-station/index-provider-peer-id'\nimport { ethers } from 'ethers'\n\n// Initialize your ethers contract instance\nconst provider = new ethers.providers.JsonRpcProvider('https://eth.example.com')\nconst contract = new ethers.Contract(\n  MINER_TO_PEERID_CONTRACT_ADDRESS,\n  MINER_TO_PEERID_CONTRACT_ABI,\n  provider,\n)\n\n// Basic usage\nconst minerId = 'f0142637'\nconst { peerId, source } = await getIndexProviderPeerId(minerId, contract)\nconsole.log(peerId) // e.g., '12D3KooWMsPmAA65yHAHgbxgh7CPkEctJHZMeM3rAvoW8CZKxtpG'\nconsole.log(source) // 'smartContract' or 'minerInfo'\n\n// Advanced usage with options\nconst { peerId, source } = await getIndexProviderPeerId(minerId, contract, {\n  maxAttempts: 3, // Number of retry attempts (default: 5)\n  rpcUrl: 'https://custom-filecoin-api.com', // Custom Filecoin RPC endpoint (default: 'https://api.node.glif.io/')\n  rpcAuth: 'your-auth-token', // Optional authorization token for RPC\n  signal: AbortSignal.timeout(60_000), // Optional AbortSignal for cancellation\n})\n```\n\n### Parameters\n\n- `minerId`: A Filecoin miner actor ID (e.g., `f0142637`)\n- `smartContract`: An ethers.js Contract instance for the Filecoin smart contract\n- `options`: (Optional) Configuration object:\n  - `maxAttempts`: Number of retry attempts for RPC calls (default: 5)\n  - `rpcUrl`: Filecoin RPC endpoint URL (default: 'https://api.node.glif.io/')\n  - `rpcAuth`: Authorization token for RPC endpoint (if required)\n  - `signal`: An AbortSignal object for cancelling the rpc request (Only effects the rpc call to the\n    Filecoin API, not the smart contract call)\n\n### Return Value\n\nReturns a Promise that resolves to the miner's PeerId string (e.g.,\n`12D3KooWMsPmAA65yHAHgbxgh7CPkEctJHZMeM3rAvoW8CZKxtpG`).\n\n### Constants\n\n#### Smart Contract Integration\n\nThis library interacts with the MinerPeerIDMapping smart contract on the Filecoin EVM to retrieve\npeer ID data.\n\n##### `MINER_TO_PEERID_CONTRACT_ADDRESS`\n\nThe Ethereum address of the deployed MinerPeerIDMapping contract.\n\n##### `MINER_TO_PEERID_CONTRACT_ABI`\n\nThe ABI required to fetch peer ID and signature data for a given miner ID.\n\nFor more information:\n\n- [Smart Contract Documentation](https://github.com/filecoin-project/curio/blob/395bc47d0f585cbc869fd4671dc05b1b2f4b18c2/market/ipni/spark/sol/README.md)\n- [Technical Background](https://docs.curiostorage.org/curio-market/ipni-interplanetary-network-indexer-provider#ipni-provider-identification)\n\n## Publish\n\nPublish a new version of `index-provider-peer-id` to npm with the following command:\n\n```bash\n$ npm run release\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckernetwork%2Findex-provider-peer-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheckernetwork%2Findex-provider-peer-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckernetwork%2Findex-provider-peer-id/lists"}