Smart Contracts
Last updated
Last updated
Smart contracts of DApps on Galactica are based on the Ethereum Virtual Machine (EVM). So developers can utilize the same libraries, frameworks and IDEs as on Ethereum.
This part of the documentation focuses on how to integrate Galactica specific features into smart contracts.
Integrating zkKYC in a DApp can be achieved by the following steps:
Choose what kind of zkKYC to require, equivalent to . Option 1: Reuse an existing zkKYC verification that satisfies your requirements. For example the Galactica passport already provides a zkKYC verification that ensures that its users are real humans with a KYC. Option 2: Build your own zkKYC verifier to include custom selective disclosures and compliance parameters. See Custom Zero Knowledge Disclosures for details. The result is a ZK circuit that compiles into a Solidity smart contract for on-chain verification.
Check if the user already passed the compliance check: To attest that users already have completed a ZkKYC verification with a DApp, they can receive a Verification SBT. If it is already present and still valid (version and expiration date), the following steps (3. and 4.) can be skipped. Verification SBTs can be queried from the .
Call verifier: To verify a ZKP submitted by the user, the following two points need to be done. You can check as a reference.
Verification of the ZKP in itself. This is done by the smart contract compiled from the circom2 circuits. It checks that the ZKP submitted by the user is a valid solution for the ZK circuit that generated the verifier. It should look similar to .
Check on-chain consistency. Because the ZKP itself has no access to the outside world, the consistency of it's parameters needs to be checked against the on-chain state. The public inputs of the ZKP disclose these parameters. This includes the root of the Merkle tree that supposedly includes the user's zkKYC, public keys of the fraud investigation institutions, and custom selective disclosures.
Create the verification SBT after a successful verification by adding it to the . This gives the user an on-chain attestation of passing the checks in step 3. Furthermore the verification SBT can also publish encrypted logs for the Galactica Investigation Module.
After checking the points above for compliance with zkKYC, the user can proceed with the DApp logic.
The zkKYC repository includes an example smart contract DApp that you can use as a reference. It implements an airdrop use case that requires a zkKYC and age proof from recipients.