SDI for dapp developers

This page describes how to interact with the x/compliance module in order to get relevant information about the verified users and issuers.

If you need help on how to get your contract verified as an issuer and start verifying users, you can read check this section: https://swisstronik.gitbook.io/swisstronik-docs/development/swisstronik-cli/for-sdi-issuers

Examples of how to interact with Swisstronik smart contracts using different frontend libraries is available here: https://github.com/SigmaGmbH/swisstronik-dapp-template

Interacting with the x/compliance module using the SwisstronikJS SDK

You'll need to install @swisstronik/sdk npm package

import { SwisstronikStargateClient } from "@swisstronik/sdk";

const client = await SwisstronikStargateClient.connect(
    "https://rpc.testnet.swisstronik.com"
);

Getting address details

It returns details for a verified address in the x/compliance module. You can use this method for both verified issuers and verified users.

const address = "swtr...";
const addressDetails = await client.queryAddressDetails(address);

The result contains information about whether the address is verified as an issuer or not, array of issuers verifications or if the verification has been revoked. Please, note that if the user address is verified by an issuer, the isVerified attribute will be false since it's true just for verified issuers. If the user is verified by an issuer, the verification array will contain elements such as the verification Id, verification type and issuer address.

Getting Issuer details

It returns issuer details by its address (name, description, url, logo and legal entity).

const issuerAddress = "swtr...";
const issuerDetails = await client.queryIssuerDetails(issuerAddress);

Getting verification details

It returns verification details by its Id (verification type, expiration timestamp, issuance timestamp, issuer address, etc.).

Getting verified address list

It returns the list of verified addresses details for both users and issuers.

Getting Issuer list

It returns the list of Issuer details.

Getting verification details list

It returns the list of Verification details.

Working demo on https://sigmagmbh.github.io/swisstronik-issuer-registry-frontend/

Interacting with the x/compliance module using Solidity

In order to get relevant x/compliance information, there's a contract deployed and ready to be used called SWTRProxy. Its code and latest address is deployed available on https://github.com/SigmaGmbH/swisstronik-sdi-contracts.

For interacting with the SWTRProxy contract in your solidity contract, you can install the @swisstronik/sdi-contracts npm package and use the ISWTRProxy interface in your contract.

How to import and initialize the SWTRProxy

From there you can call any function available in the ISWTRProxy interface

Getting list of verified Issuers

It'll return issuers name, address, and version.

Get issuer by address

Get Issuer Addresses by name and versions

There may be multiple versions/addresses for the same issuer name

The addresses are sorted in the same order the versions are passed.

Checking if an user is verified with a specific verification type by any issuer

Checking if an user is verified with a specific verification type by specific issuers

Getting verification details

Getting verification details list

Checking if user has a specific verification type

You can find the list of available functions here: https://github.com/SigmaGmbH/swisstronik-sdi-contracts

Solidity Examples

Getting an image url ONLY IF the user is has a specific verification type issued by a specific issuer

In this example only users with the VT_HUMANITY verification type issued by the specified issuer are able to view the image set by the owner. Note due to the Intel SGX, there's no other way to view the image.

Getting decoded original data of the verification by user address

In thes example, we get the decoded original data of the user verification

Typescript examples

Using web3.js and Swisstronik plugin order to check if an user has a specific verification type issued by a specific issuer

You'll need to install the plugin with npm i @swisstronik/web3-plugin-swisstronik

Getting decoded original data of the verification by user address

Note that via the SDK the addresses are specified in Bech32 (cosmos) format, and in solidity in ETH format. In some situations you may want/need to convert from Bech32 to ETH format. Or the other way around. You can do it with the @swisstronik/utils package:

Last updated