On-chain Integration
The identity.com on-chain-identity-gateway repository contains a Rust crate called integration-lib . The dApp smart contracts will call this lib to verify gateway tokens before processing a transaction.
Once the integration-lib is imported, it can be called as follows to check whether a given gateway token is valid.
The following parameters must be passed as inputs to the dApp transaction:
    userWallet : The user of the dApp (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 returned from useGateway
    gatekeeper_network The gatekeeper network on which the Civic Pass has been issued. Please contact a Civic account manager for the specific Gatekeeper Network you should use. For more information about Gatekeeper Networks, see here .
The Civic Pass (gateway token) can be accessed in the dApp through the useGateway hook on the Civic React Component , once the user has passed the Gatekeeper verification.
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 . In this case, the dApp smart contract should reject the transaction.
Last modified 14d ago
Copy link