Skip to main content

UniqueIdentity

UniqueIdentity

UniqueIdentity is an ERC1155-compliant contract for representing the identity verification status of addresses.

ID_TYPE_0

uint256 ID_TYPE_0

ID_TYPE_1

uint256 ID_TYPE_1

ID_TYPE_2

uint256 ID_TYPE_2

ID_TYPE_3

uint256 ID_TYPE_3

ID_TYPE_4

uint256 ID_TYPE_4

ID_TYPE_5

uint256 ID_TYPE_5

ID_TYPE_6

uint256 ID_TYPE_6

ID_TYPE_7

uint256 ID_TYPE_7

ID_TYPE_8

uint256 ID_TYPE_8

ID_TYPE_9

uint256 ID_TYPE_9

ID_TYPE_10

uint256 ID_TYPE_10

MINT_COST_PER_TOKEN

uint256 MINT_COST_PER_TOKEN

nonces

mapping(address => uint256) nonces

We include a nonce in every hashed message, and increment the nonce as part of a state-changing operation, so as to prevent replay attacks, i.e. the reuse of a signature.

supportedUIDTypes

mapping(uint256 => bool) supportedUIDTypes

initialize

function initialize(address owner, string uri) public

__UniqueIdentity_init

function __UniqueIdentity_init(address owner) internal

__UniqueIdentity_init_unchained

function __UniqueIdentity_init_unchained(address owner) internal

addSuperAdmin

function addSuperAdmin(address account) public

_This function allows an admin to grant superadmin rights to another address. Only admins can call this function. Requirements:

  • The calling contract must have the 'ADMINROLE'.

Parameters

NameTypeDescription
accountaddressThe address of the new superadmin.

setSupportedUIDTypes

function setSupportedUIDTypes(uint256[] ids, bool[] values) public

Sets whether a given UID type is supported by the system.

Parameters

NameTypeDescription
idsuint256[]The IDs of the UID types to be set.
valuesbool[]Whether each corresponding UID type should be supported (true) or not (false).

name

function name() public pure returns (string)

Gets the token name.

Return Values

NameTypeDescription
[0]stringstring representing the token name

symbol

function symbol() public pure returns (string)

Gets the token symbol.

Return Values

NameTypeDescription
[0]stringstring representing the token symbol

mint

function mint(uint256 id, uint256 expiresAt, bytes signature) public payable

Mints a new token to the caller's address. The function requires a valid signature from the signer contract, which proves that the caller has permission to mint tokens. It also checks if the provided id and expiresAt parameters match with the ones signed in the signature parameter.

Parameters

NameTypeDescription
iduint256The unique identifier of the token.
expiresAtuint256The timestamp after which the token is no longer valid.
signaturebytesA signature from the signer contract proving that the caller has permission to mint tokens.

mintTo

function mintTo(address recipient, uint256 id, uint256 expiresAt, bytes signature) public payable

Mints a new UniqueIdentity (UID) token for a specified recipient. The UID will have the given id, and it will expire at the provided timestamp. This function can only be called by an authorized signer with the correct signature.

Parameters

NameTypeDescription
recipientaddressAddress of the person to receive the new UID.
iduint256Unique identifier for this UID.
expiresAtuint256Timestamp after which this UID will no longer be valid.
signaturebytesSignature from an authorized signer proving they have permission to mint a new UID.

burn

function burn(address account, uint256 id, uint256 expiresAt, bytes signature) public

Burns a token from the specified account.

The caller must have signed the message with their private key to be approved.

Parameters

NameTypeDescription
accountaddressAddress of the account that owns the tokens.
iduint256ID of the token to burn.
expiresAtuint256Expiry time for the signature.
signaturebytesSignature from the signer.

burnFrom

function burnFrom(address account, uint256 id) public

Burn tokens from an account

Parameters

NameTypeDescription
accountaddressThe address of the user who owns the tokens
iduint256The unique identifier for the token

_beforeTokenTransfer

function _beforeTokenTransfer(address operator, address from, address to, uint256[] ids, uint256[] amounts, bytes data) internal

Overrides the _beforeTokenTransfer function from ERC1155PresetPauserUpgradeable contract. Only minting (from zero address to non-zero) or burning (from non-zero address to zero) transfers are allowed.

Parameters

NameTypeDescription
operatoraddressThe address which initiated the transfer.
fromaddressThe address which is sending tokens.
toaddressThe address which is receiving tokens.
idsuint256[]An array of token IDs being transferred.
amountsuint256[]An array of numbers of tokens being transferred.
databytesAdditional data with no specified format.

onlySigner

modifier onlySigner(address account, uint256 id, uint256 expiresAt, bytes signature)

onlySignerMintTo

modifier onlySignerMintTo(address mintToAddress, uint256 id, uint256 expiresAt, bytes signature)

incrementNonce

modifier incrementNonce(address account)

unlockWrongToken

function unlockWrongToken(address token) public

This function can only be called by an admin. It is used to recover tokens or native currency sent to the contract by mistake.

Allows the admin to unlock and transfer any wrongfully sent tokens from the contract to the admin's address.

Parameters

NameTypeDescription
tokenaddressThe address of the token to be unlocked. If the token address is 0, it will transfer the native currency (e.g. ETH) instead.