Skip to content

litentry/DynamicAssertion

Repository files navigation

Description

Dynamic VC assertion contract is written by solidity, using Hardhat for compilation and testing.

Environment setup

  • Install nvm
  • Inside the repository, run nvm use to set the correct Node version.
    • If the version is not installed, run nvm install.

Installation

nvm use
corepack enable pnpm
pnpm install

Usage

Develop

  1. How to create a new contract

  2. How to add a new token to token holding amount contract

  3. What is the structure of vc output

Compile

  1. Using hardhat.
pnpm compile

After compiling, the contract bytecode will generate in file artifacts/contracts/**/{contractName}.sol/{contractName}.json, e.g. the bytecode of A1 is in the file artifacts/contracts/A1.sol/A1.json.

  1. Using Remix IDE.

Should use the dynamic as your project root path in Remix IDE as below:

remixd -s your_repo_path --remix-ide https://remix.ethereum.org

If you have not installed Remixd before, run the below script to install it.

npm install -g @remix-project/remixd

Deploy

The deployment script can be used to deploy a specific contract to the specified chain. Below is the usage of the deployment script.

Command Syntax

pnpm run deploy-contract --contract <ContractName> --chain <ChainName> [--mnemonic <MnemonicValue>] [--secrets <Secret1> <Secret2> ...]

Parameters

  • --contract: Specify the name of the contract you wish to deploy.
  • --chain: Specify the target chain environment. Supported values are:
    • local
    • dev
    • staging
    • prod
  • --mnemonic: Optional, the mnemonic string required to generate the wallet for contract deployment on the staging and production chains.
  • --secrets: Optional, provide the required secret values for the contract. These may include API keys, private keys, or other sensitive information needed for the deployment contract, multiple secrets must be separated by blank, and the secret item does not support line breaks.

Example

To deploy the TokenMapping contract to the dev chain with specific secrets, you would run the following command:

pnpm run deploy-contract --contract TokenMapping --chain dev --mnemonic "angle total unfold"  --secrets "abc" "vna" "poi xyz"

Troubleshooting

  • If you meet below error, run chmod +x ./scripts/run_deploy.sh can fix it.
sh: 1: ./scripts/run_deploy.sh: Permission denied

Testing

  • Test all: pnpm test.
pnpm test
  • Test single file: pnpm test {testFilePath}.

Example:

pnpm test tests/token-holding-amount.ts