On-chain Integration
Checking for a valid Civic Pass during on-chain program execution is very straight-forward.
Simply import the integration-lib Rust crate from identity.com's on-chain-identity-gateway repository and call it when a presence of valid token is required. For example, before minting an NFT, adding a new order to an order-book or granting access to a gated section.
For your program to be able to call the integration library, the following parameters must be passed as inputs to your dApp's transaction:
  • userWallet : The wallet account for the dApp user (e.g. the trader in a defi application) . A Civic Pass must have been already issued to this wallet.
  • gateway_token : The address of the Civic Pass (token). This address can be accessed in the dApp through the useGateway hook on the Civic React Component once the user has passed Gatekeeper verification.
  • gatekeeper_network The gatekeeper network on which the Civic Pass has been issued. For more information about Gatekeeper Networks, see the-gatekeeper-network.
Get the gatekeeper_network address in the Getting Access section
1
use solana_gateway::Gateway;
2
3
// This check happens before the dApp transaction is processed
4
fn process() {
5
// The owner of the gateway token
6
let userWallet: AccountInfo;
7
// The gateway token presented by the owner
8
let gateway_token: AccountInfo;
9
// The gatekeeper network key
10
let gatekeeper_network: Pubkey;
11
12
let gateway_verification_result:Result<(), GatewayError> =
13
Gateway::verify_gateway_token_account_info(
14
&gateway_token_account_info, &userWallet.key, &gatekeeper
15
);
16
}
Copied!

Error handling

The Gateway call will return a GatewayError if something goes wrong or the token is invalid. The possible values can be seen in error.rs . For error cases, the dApp smart contract should reject the transaction.
Last modified 25d ago
Copy link