The XDC Zero Endpoint is a foundational cross-chain contract that enables seamless reception and dispatch of data packets across diverse blockchain networks.
- Initialization: Set the
chainId
for the current blockchain. - Register Chain: Introduce a new blockchain, providing its unique identifier, checkpoint contract, and endpoint contract.
- Send Packet: Dispatch a data packet to a specified receiving chain.
- Validate Transaction Proof:
- Monitor payload event data via a relayer from the sending chain's Zero Endpoint contract.
- Deduce the
rid
(receiver's chainId). - Execute the
validateTransactionProof
method on the recipient chain, authenticating and archiving the transaction payload.
- Retrieve Payload: Applications, identified by
ra
, can easily access the cross-chain payload from the Zero Endpoint contract.
- Install Dependencies:
yarn
- Compile & Test:
npx hardhat test
- Configuration Files:
-
xdcparentnet
: Contains parameters for deploying the parentnet endpoint. -
xdcsubnet
: Contains parameters for deploying the subnet endpoint.-
endpoint
: Current address of the chain endpoint. -
registers
: Parameters for registering specific details.csc
: Checkpoint smart contract address within this chain.chainId
: Identifies the Chain ID of the corresponding chain. (e.g., if set inxdcparentnet
, the other side refers to the subnet).endpoint
: Address of the endpoint for the register chain.
-
applications
: Parameters for application specific details.rid
: receive chain idrua
: receive chain user applicationsua
: send chain user application
-
xdcparentnet
: RPC URL for the parentnet.xdcsubnet
: RPC URL for the subnet.
- Environment Variables:
- Set up a
.env
file based on.env.sample
and provide a valid private key.
- Set up a
To begin deployment, start with the subnet endpoint:
npx hardhat run scripts/endpointdeploy.js --network xdcsubnet
Also start the parentnet endpoint:
npx hardhat run scripts/endpointdeploy.js --network xdcparentnet
Next, configure the registration parameters in the endpointconfig.json
file for the chain:
npx hardhat run scripts/registerchain.js --network xdcsubnet
Also register on the parentnet:
npx hardhat run scripts/registerchain.js --network xdcparentnet
After setting the application parameters in endpointconfig.json
, proceed to register the user application (check applications/subswap for an example on deploying application):
npx hardhat run scripts/registerapplications.js --network xdcsubnet
npx hardhat run scripts/registerapplications.js --network xdcparentnet
For comprehensive functionalities or deeper insights, refer to the command list below:
npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
npx hardhat help
REPORT_GAS=true npx hardhat test
npx prettier '**/*.{js,json,sol,md}' --check
npx prettier '**/*.{js,json,sol,md}' --write
npx solhint 'contracts/**/*.sol'
npx solhint 'contracts/**/*.sol' --fix