|
| 1 | +# Generating Local Network Context for Lit Protocol |
| 2 | + |
| 3 | +The Lit network contexts, which include smart contract addresses and ABIs, typically come from the `@lit-protocol/contracts` package (a separate repository at https://github.com/LIT-Protocol/lit-contracts/). However, these contexts are designed for established networks. |
| 4 | + |
| 5 | +## Local Network Setup |
| 6 | + |
| 7 | +For local development (running Lit nodes on your machine), you need to generate a `networkContext.json` file in the `lit-assets` directory. This is typically done by running the deploy script after starting your local Anvil chain. |
| 8 | + |
| 9 | +## Version Compatibility Changes |
| 10 | + |
| 11 | +In version 7 or earlier, you could simply copy and paste the `networkContext.json` file, and it would work when setting the network to `custom` when running with Tinny (E2E test suite). |
| 12 | + |
| 13 | +However, in version 8, we've optimised by removing redundant and unused ABIs from the JSON file and enforced strongly typed ABIs. This optimization introduced an additional conversion layer that extracts only the necessary ABI methods, which must be run manually for local network contexts. |
| 14 | + |
| 15 | +## Generating Custom Context |
| 16 | + |
| 17 | +To generate the proper context: |
| 18 | + |
| 19 | +1. Locate the `getCustomContext` file in the network-specific folder (in this case, `vNaga/naga-develop` folder) |
| 20 | +2. Use the `generateSignaturesFromContext` helper function from the `@lit-protocol/contracts` repository |
| 21 | + |
| 22 | +Here's an example of how to use this function: |
| 23 | + |
| 24 | +```ts |
| 25 | +import { generateSignaturesFromContext } from "@lit-protocol/contracts/custom-network-signatures"; |
| 26 | + |
| 27 | +await generateSignaturesFromContext({ |
| 28 | + jsonFilePath: |
| 29 | + "/Users/anson/Projects/lit-assets/blockchain/contracts/networkContext.json", // in lit assets repo |
| 30 | + networkName: "naga-develop", |
| 31 | + outputDir: "./naga-develop-signatures", |
| 32 | + useScriptDirectory: true, |
| 33 | + callerPath: import.meta.url, |
| 34 | +}); |
| 35 | +``` |
0 commit comments