- Install node.js 20+
- Install solidity compiler:
- solc-select
- or svm-rs
- or manually install a specific version if you are working with only one version.
Regenerate after you change contract source.
- Install solidity compiler
- Run
go generate
npm install
npx hardhat compile
npx hardhat test
npx hardhat test --grep Bridge
npx hardhat coverage
npx hardhat coverage --testfiles test/Bridge/bridge.test.ts
The contracts in contracts/testing are used for unit testing and performance benchmarks.
These contracts in contracts/libs are external dependencies and libraries. Some old libraries are kept to support other legacy contracts.
kip13/InterfaceIdentifier.sol: The ERC-165 supportsInterface.openzeppelin-contracts-v2/*: OpenZeppelin contracts.Ownable.sol: Ownable contract.SafeMath.sol: SafeMath for older solidity versions.ValidContract.sol: Check if the contract is valid.
Some libraries are outside /contracts directory and are installed via npm
node_modules/@openzeppelin/contracts: OpenZeppelin contracts.node_modules/openzeppelin-contracts-5.0: OpenZeppelin contracts v5.0.
These contracts in contracts/service_chain are the service chain token bridges.
bridge/*.sol: Token bridge implementation.- The
subbridge_deployBridgeAPI deploys this contract.
- The
sc_erc20/IERC20BridgeReceiver.sol: onERC20Received interface.sc_erc721/IERC721BridgeReceiver.sol: onERC721Received interface.
These contracts in contracts/system_contracts are deployed or planned to be deployed on the mainnet.
consensus/AddressBook.sol: The validator registry.- Deployed at address 0x400: testnet, mainnet
- Deployed at the genesis block in 2018, active to date.
consensus/CnStakingContract.sol: Validator (CN) staking contract V1.- Deployed instances: search, example1, example2
- Introduced since genesis in 2018, currently deprecated over KIP-82's CnStakingV2. The V1 to V2 migration has started since March 2023 and still some V1 instances remain active (i.e. registered in AddressBook).
gov/GovParam.sol: On-chain storage for governance parameters.- Deployed instance: testnet, not on mainnet.
- Introduced with v1.10.0 in Dec 2022, not been used after a test drive in testnet.
kip103/TreasuryRebalance.sol: The KIP-103 treasury rebalance implementation.kip113/SimpleBlsRegistry.sol: The KIP-113 BLS public key registry.kip149/Registry.sol: The KIP-146 system contract registry.kip163/CnStakingV3MultiSig.sol: TBA.- Not deployed yet.
kip163/PublicDelegation.sol: TBA.- Not deployed yet.
misc/credit.sol: The credit data.- Deployed at address 0x0, not on testnet.
- Deployed at the genesis block in 2018, relevant to date.
proxy/proxy.sol: The ERC1967 Upgradable Proxy.