Civic Docs
Search
K
Comment on page

SDK Integration

Use Cases
  • Utilize addresses to gain access to rich profile information
  • Check for Civic Passes - Provides verification properties of addresses such as age check, uniqueness, ID document verification, and KYC.
Use the rich profile information to personalize your user's experience:

Loading the Profile Data

Import the SDK and load a profile as follows:
import { CivicProfile, Profile } from "@civic/profile";
...
// Query a user's profile using a wallet address, did or .sol domain
const profile: Profile = await CivicProfile.get(user);
The profile result will contain the following data:
// The resolved public key
profile.address
// The resolved did
profile.did
// A civic.me profile name, if available
profile.name?.value
// A civic.me profile image, if available
profile.image?.url
// A civic.me profile headline, if available
profile.headline?.value

Getting a list of Civic Passes for a Wallet

This returns a list of Civic passes owned by the profile's keys.
Solana
Ethereum + EVMs
// A Solana Connection is required in order to query for passes. Public devnet used as an example here:
import { Connection, clusterApiUrl } from "@solana/web3.js";
import { CivicProfile, Profile, GatewayToken } from "@civic/profile";
const solanaConnection: Connection = new Connection(clusterApiUrl("devnet"));
const profile: Profile = await CivicProfile.get(user, { solana: { connection }});
const passes: GatewayToken[] = await profile.getPasses();
By default, multiple pass types are queried. A blockchain RPC call is made for each combination of public key & pass type. The list of pass types to query can be overridden. A pass type is represented by its corresponding Gatekeeper Network address.
const passes: GatewayToken[] = await profile.getPasses(["ni1jXzPTq1yTqo67tUmVgnp22b1qGAAZCtPmHtskqYG"]);
// An Ethereum Connection is required in order to query for passes. Public devnet used as an example here:
import { getDefaultProvider } from "@ethersproject/providers";
import { CivicProfile, Profile, GatewayToken } from "@civic/profile";
const provider = getDefaultProvider();
const profile: Profile = await CivicProfile.get(user, { ethereum: { connection }});
const passes: GatewayToken[] = await profile.getPasses();
By default, multiple pass types are queried. A blockchain RPC call is made for each combination of pass types. The list of pass types to query can be overridden. A pass type is represented by its corresponding Gatekeeper Network address.

Supported Gateway Token Types

Depending on the Gateway Token it can either be a token from Solana or an EVM supported chain. The token has the following properties which are different between chains.
type BaseGatewayToken = {
readonly issuingGatekeeper: string;
readonly gatekeeperNetworkAddress: string;
readonly owner: string;
readonly state: string;
readonly expiration?: number;
readonly chain: Chain;
};
type EthereumTokenMetadata = {
readonly tokenId: number;
readonly chainId: number;
readonly bitmask: number;
readonly tokenURI?: string;
readonly contractAddress: string;
};
type SolanaTokenMetadata = {
readonly tokenAddress: string;
readonly programId: string;
};
export type SolanaGatewayToken = BaseGatewayToken & SolanaTokenMetadata;
export type EthereumGatewayToken = BaseGatewayToken & EthereumTokenMetadata;
export type GatewayToken = SolanaGatewayToken | EthereumGatewayToken;