These contracts govern the Lit Nodes and various PKP things. Currently in testnet only.
You can find the corresponding addresses for each network here: https://github.com/LIT-Protocol/networks
In order to run the contract tests, you will need to follow these instrucitons:
- Start an instance of our forked Anvil locally. The forked Anvil contains a precompile for the key derivation function and can be found here: https://github.com/LIT-Protocol/foundry
- Run
npm run test
npx hardhat verify --network celo 0x5Ef8A5e3b74DE013d608740F934c14109ae12a81 \
"0x0008a7B1Ce657E78b4eDC6FC40078ce8bf08329A"
The second param is any constructor params.
- Run
npm install
to install project dependencies. npx ts-node scripts/deploy.ts --network <NETWORK>
where you will typically use "lit" as the network (which is the Chronicle chain)
- If you know exactly which deployment full config file you would like to use, you can do
npm run deploy -- --deploy-config <DEPLOY_FULL_CONFIG_PATH>
. The--network
option is not needed here as the deploy config file contains that parameter.
Note: The wallet you provide should have at least 10 LIT for the gas to complete the entire deployment process which includes funding & staking the nodes which is called internally in the deploy script. If you don't have that much LIT you may ask Chris on Slack for it. You could also get some from the Chronicle Faucet but it only gives out a tiny amount so you would have to modify the deploy scripts to fund each of the node wallets with less tokens.
Note: The deploy script will set the ownership of each contract to the newOwner
address defined in scripts/deploy_lit_node_contracts.js. If you need to call owner / admin functions on the contracts after they're deployed, you can set that newOwner
address to something you control. If you're just using the contracts with the nodes you probably don't need to do this.
Once this script is done running, if you answered "y" to "Should we copy the node config files into the node folder", there will be config files for you generated in /node_configs of this repo. You can copy these to the /config folder of the lit_node_rust repo.
These are the instructions for deploying + the smart contracts locally:
- Run a local blockchain / testnet using Hardhat, Anvil or other software. It must be listening on port
8545
onlocalhost
. npm run deploy -- --network localchain
and follow the interactive prompts.- Select
dev
for the environment. - Specify a wallet address that you own / have access to when specifying the
newOwnerAddress
. - Accept to copy the node configs to the Rust project.
- Choose anywhere from 3 to 10 for the number of node wallets.
- Use the default IP addresses as suggested.
Here is an example deployment configuration:
{
"deploymentSelection": "lit-core + lit-node",
"deployNodeConfig": {
"environment": "dev",
"networkName": "localchain",
"newOwnerAddress": "0x4259E44670053491E7b4FE4A120C70be1eAD646b",
"numberOfStakedOnlyWallets": 3,
"resolverContractAddress": "TBD",
"useLitCoreDeploymentResolverContractAddress": true,
"outputTempFilePath": "./deployed-lit-node-contracts-temp.json",
"copyNodeConfigsToRustProject": true,
"ipAddresses": ["127.0.0.1:7470", "127.0.0.1:7471", "127.0.0.1:7472"]
},
"deployCoreConfig": {
"environment": "dev",
"networkName": "localchain",
"subnetOwnerAddress": "0xB77AEBbC262Bb809933D991A919A0e4A6A3b2f65",
"subnetAdminPublicKey": "0x045f96e860435fccf287d9c2592fa129edfca7159c8dd2260cf2def38a9d5ee627ba73afef636467bc95fe551f10c862e910f18eafb751226d6901eab7d5b2794a",
"subnetProvAddress": "0x3324439C8b9181eF07D54030E32d2CD22FF0C6A7",
"outputTempFilePath": "./deployed-lit-core-contracts-temp.json"
}
}
We have developed a tool that makes it convenient to deploy and configure our suite of smart contracts before spinning up a network of nodes against them. Specifically, our tool helps with:
- Deploying Lit Core and/or Lit Node smart contracts to any supported chain
- After deploying smart contracts, configure the smart contract parameters and settings per each of the node operators
- The tool is available as a
npm
script -npm run deploy -- --network <NETWORK>
- The currently supported network names are:
celo
mumbai
alfajores
polygon
litTestnet
lit
localchain
- The currently supported network names are:
- At a high-level, the tool consists of 2 main steps:
- An interactive step that determines the entire set of deployment configurations that will be used.
- A non-interactive step that takes a deployment configuration and deploys and configures a set of smart contracts accodingly.
- Running the entire tool as it is will involve an interactive experience (eg. command-line experience). If you wish to have a non-interactive experience, that is only available by running the tool and specifying exactly which deployment configuration you would like to use, ie.
npm run deploy -- --deploy-config <DEPLOY_FULL_CONFIG_PATH>
. The--network
option is not needed here as the deploy config file contains that parameter. - The non-interactive deployment step is run as a child process that is spawned. All environment variables are inherited in the spawned environment. We pass in additional environment variables.
- When running the interactive first step,
- you will have the option to choose whether to deploy:
- Only the Lit Core contracts
- Only the Lit Node contracts
- Both the Lit Core and Lit Node contracts, and in that order.
- you will have the option to choose a previously generated deployment configuration.
- This is the true power of this tool, in allowing you to reference EXACTLY a deployment configuration that has worked well for your needs previously.
- you will have the option to choose whether to deploy:
- This tool is environment-aware and will ask for confirmation before proceeding to use parameters specified in your shell session. Refer to the Deployment Configuration Reference section below for more details.
- This tool uses
inquirer.js
to create the interactive experience.
The deployment configuration refers to the entire set of parameters that will be used for deploying and configuring the smart contracts.
- Each deployment configuration is persisted to disk locally under the
scripts/deployConfig/configs
directory. - In order for a persisted deployment configuration to be detected by the tool, it must match the following pattern
deploy-config-*.json
Here is an explanation for each of the fields in the deployment configuration:
Key Path | Type | Description |
---|---|---|
deploymentSelection |
string |
An enum of either lit-core , lit-core + lit-node or lit-node describing which set of smart contracts should be deployed. |
deployNodeConfig |
object |
The deployment configuration parameters that relate to deploying the Lit Node smart contracts. |
deployNodeConfig.environment |
string |
An enum of either dev , staging or prod describing which deployment environment the Lit Node contracts should be deployed to. |
deployNodeConfig.networkName |
string |
The name of the network (chain) the Lit Node contracts should be deployed to. |
deployNodeConfig.newOwnerAddress |
string |
The EVM-compatible address that will be given ownership and configuration permissions once the tool finishes. While the tool uses the deployer address to configure the smart contract parameters after deployment, you would most likely want to revoke admin / owner permissions from the deployer and grant your own address such permissions after the tool finishes. If LIT_OWNER_WALLET_ID is set in your environment, the tool will ask for confirmation before using this parameter. |
deployNodeConfig.numberOfStakedOnlyWallets |
number |
The number of nodes (and node operators) that only stake on the network. |
deployNodeConfig.numberOfStakedAndJoinedWallets |
number |
The number of nodes (and node operators) that stake and request to join the network. If a node is already accounted for in deployNodeConfig.numberOfStakedOnlyWallets , do not account for that node here, as the total number of stakers will be the sum of the two. The nodes that are joining will be the first numberOfStakedAndJoinedWallets entries from the overall node wallets list that is generated. |
deployNodeConfig.resolverContractAddress |
string |
The Lit Core ContractResolver contract address that will be referenced. It will be marked as TBD when deployNodeConfig.useLitCoreDeploymentResolverContractAddress is set to true , since we won't know the smart contract address until the non-interactive deployment step of the tool. If LIT_RESOLVER_CONTRACT_ADDRESS is set in your environment, the tool will ask for confirmation before using this parameter. |
deployNodeConfig.useLitCoreDeploymentResolverContractAddress |
boolean |
Whether to use the ContractResolver contract address from deploying the Lit Core contracts. |
deployNodeConfig.outputTempFilePath |
string |
The path to the file containing the addresses of the deployed Lit Node smart contracts. |
deployNodeConfig.copyNodeConfigsToRustProject |
boolean |
Whether to copy the generated node configs over to the Rust project. You will likely need this when spinning up a network locally on your machine. |
deployNodeConfig.ipAddresses |
string[] |
An array of strings representing the IP addresses of the node operators. You will likely need this when spinning up a network locally on your machine. If IP_ADDRESSES is set in your environment, the tool will ask for confirmation before using this parameter. |
deployNodeConfig.existingRouterAndPkpContracts |
object |
An object containing the addresses of smart contracts from a prior deployment to be referenced again in this current deployment. |
deployCoreConfig |
object |
The deployment configuration parameters that relate to deploying the Lit Core smart contracts. |
deployCoreConfig.environment |
string |
An enum of either dev , staging or prod describing which deployment environment the Lit Core contracts should be deployed to. |
deployCoreConfig.networkName |
string |
The name of the network (chain) the Lit Core contracts should be deployed to. |
deployCoreConfig.subnetOwnerAddress |
string |
The address of the subnet owner. |
deployCoreConfig.subnetAdminPublicKey |
string |
The public key of the subnet admin. |
deployCoreConfig.subnetProvAddress |
string |
The address of the wallet that provisions the subnet. |
deployCoreConfig.outputTempFilePath |
string |
The path to the file containing the addresses of the deployed Lit Core smart contracts. |
deploySensitiveConfig |
string |
The deployment configuration parameters that are sensitive. These parameters are never stored to disk and are only provided via the environment. |
deploySensitiveConfig.ipfsApiKey |
string |
The IPFS API key |
Deployed contract addresses are listed by network in this repo: https://github.com/LIT-Protocol/networks