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).
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.
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.
// SPDX-License-Identifier: UNLICENSEDpragmasolidity ^0.8.24;import {EIP712} from"@openzeppelin/contracts/utils/cryptography/EIP712.sol";import {ECDSA} from"@openzeppelin/contracts/utils/cryptography/ECDSA.sol";import {Ownable} from"@openzeppelin/contracts/access/Ownable.sol";import {ISWTRProxy} from"@swisstronik/sdi-contracts/contracts/interfaces/ISWTRProxy.sol";enumAdapterType { Quadrata, WorldCoin}contractSampleisOwnable, EIP712 { string internal imageUrl; // Thanks to Intel SGX encryption, there's no way to know the value of this variable by checking the storage slot
ISWTRProxy public swtrProxy;constructor(ISWTRProxy_swtrProxy ) EIP712("Sample Dapp", "1") Ownable(msg.sender) { swtrProxy = _swtrProxy; }functionsetImageUrl(stringmemory_imageUrl) publiconlyOwner { imageUrl = _imageUrl; }functiongetImageUrl(bytescalldata signature ) publicviewreturns (stringmemory) {require(bytes(imageUrl).length >0,"Image URL not set");address userAddress =recoverSigner(signature);uint32[] memory versions =newuint32[](1); versions[0] =1;address[] memory allowedIssuers = swtrProxy.getIssuerAddressesByNameAndVersions("Worldcoin", versions );bool isVerified = swtrProxy.isUserVerifiedBy( userAddress, ISWTRProxy.VerificationType.VT_HUMANITY, allowedIssuers );require(isVerified,"User not verified");return imageUrl; }functionrecoverSigner(bytescalldata signature ) publicviewreturns (address) {bytes32 structHash =keccak256( abi.encode(keccak256("Obj(string contents)"),keccak256("Sample Verification") ) );bytes32 digest =_hashTypedDataV4(structHash);return ECDSA.recover(digest, signature); }}
Getting decoded original data of the verification by user address
In thes example, we get the decoded original data of the user verification
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: