Comment on page
Fractal DID registry
Authorize transactions by looking up their sender on Fractal's DID Registry.
Both Credentials API and DID Registry enable you to verify the credentials associated with a wallet address in your smart contract (on-chain) or in your dApp.
The DID Registry is a smart contract Fractal has deployed which contains two public methods your dApp and smart contract can call to verify a credential. Registries are deployed on Karura, Binance, Avalanche, Goerli (demos only), Gnosis, Aurora (soon) and Polygon. Registries will be deployed on other chains on a demand basis.
In order to verify a credential, you call
getFractalId()
to get a fractalId
associated with a wallet address. Every fractalId
in the DID Registry corresponds to a unique human. You call isUserInList()
to determine whether a fractalId
exists in one of the Registry's maintained lists. Only client-specific lists are currently maintained.The advantages of the DID Registry are:
- No need to access or manage personal data. You only need the user's connected wallet address to interact with the Registry.
- No need to change the user flow. Once a user has connected their wallet, your dApp can call the Registry in the background in order to verify their credentials. The user does not need to do anything more.
- Same interface. The interface used by your dApp and your smart contract is the same.

A unique human has a unique Fractal ID, each with 1+ addresses and present in 0+ lists.
address [*]---[1] fractalId [*]---[*] listId
Getting the Fractal ID for an address
bytes32 fractalId = getFractalId(address walletAddress);
Looking for a Fractal ID in a list
bool presence = isUserInList(bytes32 fractaId, string listId);
Every
fractalId
in the DID Registry corresponds to a unique human. Aditionally, you can also make use of the following lists.listId | Meaning |
---|---|
client_custom_list | These are custom lists created for clients that have KYC compliance needs that don't fit the above lists. |
- 1.Import our
FractalRegistry.sol
contract and set its address. - 2.Adapt the
requiresRegistry
modifier
based on your KYC level and country requirements.
import {FractalRegistry} from "github.com/trustfractal/registry-deployer/blob/master/contracts/FractalRegistry.sol";
contract Main {
FractalRegistry registry = FractalRegistry(0x5FD6eB55D12E759a21C09eF703fe0CBa1DC9d88D);
function requiresRegistry(
address sender,
string[1] memory requiredLists,
string[2] memory blockedLists
) private view {
bytes32 fractalId = registry.getFractalId(sender);
require(fractalId != 0);
for (uint256 i = 0; i < requiredLists.length; i++) {
require(registry.isUserInList(fractalId, requiredLists[i]));
}
for (uint256 i = 0; i < blockedLists.length; i++) {
require(!registry.isUserInList(fractalId, blockedLists[i]));
}
}
function main(
/* your transaction arguments go here */
) external view {
requiresRegistry(msg.sender, ["client_custom_list_id"], []);
/* your transaction logic goes here */
}
}
The example above adds approximately 25k gas to the transaction cost. Gas usage increases with the number of lookups.
The interface to the Registry in the demo can be found in
miniBackoffice.ts
. The specific two functions are fetchFractalId
and fetchKycState
.const fetchFractalId = (
signer: providers.JsonRpcSigner,
account: string
): Promise<string> => fractalRegistry.connect(signer).getFractalId(account);
const fetchKycStatus = (
signer: providers.JsonRpcSigner,
fractalId: string
): Promise<boolean> =>
fractalRegistry.connect(signer).isUserInList(fractalId, KYCList);
If you want to understand more deeply how our registries work, check out our developer demo. Or, you can review the registry smart contract along with a simple environment to deploy it here.
Last modified 7mo ago