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
Name | Type | Description |
---|---|---|
account | address | The 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
Name | Type | Description |
---|---|---|
ids | uint256[] | The IDs of the UID types to be set. |
values | bool[] | 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
Name | Type | Description |
---|---|---|
[0] | string | string representing the token name |
symbol
function symbol() public pure returns (string)
Gets the token symbol.
Return Values
Name | Type | Description |
---|---|---|
[0] | string | string 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
Name | Type | Description |
---|---|---|
id | uint256 | The unique identifier of the token. |
expiresAt | uint256 | The timestamp after which the token is no longer valid. |
signature | bytes | A 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
Name | Type | Description |
---|---|---|
recipient | address | Address of the person to receive the new UID. |
id | uint256 | Unique identifier for this UID. |
expiresAt | uint256 | Timestamp after which this UID will no longer be valid. |
signature | bytes | Signature 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
Name | Type | Description |
---|---|---|
account | address | Address of the account that owns the tokens. |
id | uint256 | ID of the token to burn. |
expiresAt | uint256 | Expiry time for the signature. |
signature | bytes | Signature from the signer. |
burnFrom
function burnFrom(address account, uint256 id) public
Burn tokens from an account
Parameters
Name | Type | Description |
---|---|---|
account | address | The address of the user who owns the tokens |
id | uint256 | The 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
Name | Type | Description |
---|---|---|
operator | address | The address which initiated the transfer. |
from | address | The address which is sending tokens. |
to | address | The address which is receiving tokens. |
ids | uint256[] | An array of token IDs being transferred. |
amounts | uint256[] | An array of numbers of tokens being transferred. |
data | bytes | Additional 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
Name | Type | Description |
---|---|---|
token | address | The address of the token to be unlocked. If the token address is 0, it will transfer the native currency (e.g. ETH) instead. |