Handling identities

In order to receive tokens, Identities must be added in the Identity Registry of the Token, which is a Smart Contract. The methods described in this section are used to retrieve and manage identities within the scope of a Token.

Read methods

Check if a Wallet is registered

This method verifies if the Wallet is present in the Identity Registry and if it is associated with an Identity. Note that the wallet is an address that owns the tokens. It can also be a Smart Contract.

await token.isWalletRegistered('WALLET ADDRESS');

Get Identity associated with Wallet

If a Wallet is in the Identity Registry, it is associated with an Identity that you can retrieve as an Identity object from the OnchainID SDK. If the wallet is not registered, this function will return null.

const identityAddress = await token.getIdentityAddress('WALLET ADDRESS');
console.log(identityAddress);

Check Identity of Wallet Compliance

This method verifies that a wallet is associated with a compliant Identity by calling the .isVerified method of the Identity Registry, as defined in the T-REX standard.

await token.isIdentityOfWalletCompliant('WALLET ADDRESS');

Write methods

Register Identity by Wallet

To register an Identity that is not yet registered, pass the identity address and the country (iso integer) of the holder as an argument to the wallet. This method is forwarded to the Identity Registry instance of the Token.

The specified wallet must not be registered with an identity yet on this Registry if it is the call will throw a WalletAlreadyRegisteredError

const tx = await token.registerIdentityOfWallet({
  country: COUNTRY CODE, // ISO-3166-NUMERIC CODE
  identityAddress: 'IDENTITY/ONCHAINID ADDRESS',
  wallet: 'WALLET ADDRESS',
});

Update Identity registered with a wallet

To change the Identity registered with a wallet, use the updateIdentity method:

const tx = await token.updateIdentityOfWallet({
  newIdentityAddress: 'NEW IDENTITY/ONCHAINID ADDRESS',
  wallet: 'WALLET ADDRESS',
})

Update country of Wallet

const tx = await token.updateCountryOfWallet({
  newCountry: NEW COUNTRY CODE,
  wallet: 'WALLET ADDRESS',
});

Unregister Identity

Warning: This operation will remove the Identity from the Registry, and breaks the link between the wallet and the Identity. You should not call this method for wallets that still hold tokens.

const tx = await token.unregisterIdentityOfWallet({
  wallet: 'WALLET ADDRESS',
});