For the complete documentation index, see llms.txt. This page is also available as Markdown.

Add KYC Certificate

This guide shows the steps needed to obtain and add a KYC certificate to an account. It uses the Footprint sandbox anchor for demonstration purposes and the Anchor Resolver to search for the provider.

1

Prepare your account

Generate the account to add the certificate to

2

Create a UserClient

A UserClient is used to interact with Keeta

await using userClient = KeetaAnchor.KeetaNet.UserClient.fromNetwork(
  network,
	userAccount
);
3

Create an Anchor KYC Client

Anchor clients use a UserClient and add Anchor specific interactions like KYC, FX and Asset Movement

const kycClient = new KeetaAnchor.KYC.Client(userClient);
4

Get available providers

This will search the Anchor Registry for KYC Anchors that support the provided details (eg. US country code in this example)

const providers = await kycClient.createVerification({
  countryCodes: ['US'],
	account: userAccount
});
5

Start the KYC Verification

We'll use the provider matching the "Footprint" id in this step. Sandbox has 2 providers, a basic demo provider as well as the Footprint provider. Then start the verification. The result of starting verification returns a webURL that can be used to complete the KYC Verification with the KYC Anchor.

const provider = providers.find((p) => p.id === "Footprint");
const verification = await provider.startVerification();

console.log(verification.webURL);
6

Get KYC Certificate from Provider

Once the KYC Verification is complete, we can obtain the KYC Certificate from the Anchor.

const certificates = await verification.getCertificates();
7

Add KYC Certificate to User Account

The KYC Anchor returns the leaf certificate and intermediates that can be used to construct the chain of authority. We can then add the certificates to the account. If the Anchor returns multiple certificates we can iterate through all of them.

for (const [i, certGroup] of certificates.results.entries()) {
  // Re-wrap with the user's account as the subject key so sensitive
	// attributes (PII) can be decrypted
	const cert = new KeetaAnchor.lib.Certificates.Certificate(
		certGroup.certificate.toPEM(),
		{ subjectKey: userAccount }
	);

	// Construct the Certificate Bundle from Intermediates
	const intermediates = certGroup.intermediates
	  ? new KeetaAnchor.KeetaNet.lib.Utils.Certificate.CertificateBundle([...certGroup.intermediates])
		: null;
			
	// Attach the certificate to the user's account onchain
	await userClient.modifyCertificate(
	  KeetaAnchor.KeetaNet.lib.Block.AdjustMethod.ADD,
		cert,
		intermediates
	);
}
8

Read Certificates from User Account

const onChain = await userClient.client.getAllCertificates(userAccount);
console.log(`\nOn-chain certificates for this account: ${onChain.length}`);

Full Code Example

https://github.com/KeetaNetwork/keetanet-examples/blob/main/src/anchor/kyc-client.ts

Last updated