EVMAuth6909
Inherits: ERC6909MetadataUpgradeable, ERC6909ContentURIUpgradeable, EVMAuth
Author: EVMAuth
Multi-token authentication contract implementing ERC-6909 with time-based access control.
Extends ERC-6909 with authorization features including time-to-live tokens, role-based access, and configurable purchasing mechanisms. Implements UUPS upgradeable pattern for future enhancements.
Functions
initialize
Initializes the EVMAuth6909 contract with admin and treasury configuration.
Initializer used when deployed directly as an upgradeable contract.
function initialize(
uint48 initialDelay,
address initialDefaultAdmin,
address payable initialTreasury,
RoleGrant[] calldata roleGrants,
string memory uri_
) public virtual initializer;
Parameters
Name | Type | Description |
---|---|---|
initialDelay | uint48 | Delay in seconds before a new default admin can exercise their role |
initialDefaultAdmin | address | Address to be granted the initial default admin role |
initialTreasury | address payable | Address where purchase revenues will be sent |
roleGrants | RoleGrant[] | Array of initial role assignments |
uri_ | string | Contract URI per EIP-6909 content URI extension |
__EVMAuth6909_init
Internal initializer that sets up all parent contracts.
Calls parent initializers in correct order for upgradeable contracts.
function __EVMAuth6909_init(
uint48 initialDelay,
address initialDefaultAdmin,
address payable initialTreasury,
RoleGrant[] calldata roleGrants,
string memory uri_
) internal onlyInitializing;
Parameters
Name | Type | Description |
---|---|---|
initialDelay | uint48 | Delay in seconds before a new default admin can exercise their role |
initialDefaultAdmin | address | Address to be granted the initial default admin role |
initialTreasury | address payable | Address where purchase revenues will be sent |
roleGrants | RoleGrant[] | Array of initial role assignments |
uri_ | string | Contract URI per EIP-6909 content URI extension |
__EVMAuth6909_init_unchained
Unchained initializer for contract-specific storage.
Sets the contract URI for ERC-6909 content URI support.
function __EVMAuth6909_init_unchained(string memory uri_) internal onlyInitializing;
Parameters
Name | Type | Description |
---|---|---|
uri_ | string | Contract URI per EIP-6909 content URI extension |
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC6909Upgradeable, AccessControlDefaultAdminRulesUpgradeable, IERC165)
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
balanceOf
Gets current balance excluding expired tokens.
Iterates through balance records and sums non-expired amounts.
function balanceOf(address account, uint256 id)
public
view
virtual
override(ERC6909Upgradeable, IERC6909, TokenEphemeral)
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
account | address | Address to check balance for |
id | uint256 | Token type identifier |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total non-expired balance |
mint
Mints new tokens of a specific type to an account.
Restricted to addresses with MINTER_ROLE.
function mint(address to, uint256 id, uint256 amount) external onlyRole(MINTER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
to | address | Recipient address for minted tokens |
id | uint256 | Token type identifier to mint |
amount | uint256 | Quantity of tokens to mint |
burn
Burns tokens of a specific type from an account.
Restricted to addresses with BURNER_ROLE.
function burn(address from, uint256 id, uint256 amount) external onlyRole(BURNER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
from | address | Address to burn tokens from |
id | uint256 | Token type identifier to burn |
amount | uint256 | Quantity of tokens to burn |
setContractURI
Updates the contract-level metadata URI.
Restricted to addresses with TOKEN_MANAGER_ROLE.
function setContractURI(string memory contractURI) external virtual onlyRole(TOKEN_MANAGER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
contractURI | string | New contract metadata URI |
setTokenURI
Updates the metadata URI for a specific token type.
Restricted to addresses with TOKEN_MANAGER_ROLE.
function setTokenURI(uint256 id, string memory contentURI) external virtual onlyRole(TOKEN_MANAGER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | Token type identifier to update |
contentURI | string | New metadata URI for this token type |
setTokenMetadata
Updates the on-chain metadata for a specific token type.
Restricted to addresses with TOKEN_MANAGER_ROLE. Sets name, symbol, and decimals.
function setTokenMetadata(uint256 id, string memory name, string memory symbol, uint8 decimals)
external
virtual
onlyRole(TOKEN_MANAGER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | Token type identifier to update |
name | string | Display name for the token type |
symbol | string | Trading symbol for the token type |
decimals | uint8 | Number of decimal places for token amounts |
_burnPrunedTokens
Internal hook to handle burning of pruned tokens.
Override this function to integrate with the token standard's burn mechanism. Called automatically during pruning if expired tokens are found.
function _burnPrunedTokens(address account, uint256 id, uint256 amount) internal virtual override;
Parameters
Name | Type | Description |
---|---|---|
account | address | Address from which tokens were pruned |
id | uint256 | Token type identifier |
amount | uint256 | Quantity of tokens that were pruned (expired) |
_mintPurchasedTokens
Abstract function to mint purchased tokens.
Must be implemented by inheriting contracts.
function _mintPurchasedTokens(address to, uint256 id, uint256 amount) internal virtual override;
Parameters
Name | Type | Description |
---|---|---|
to | address | Address to receive minted tokens |
id | uint256 | Token type identifier |
amount | uint256 | Quantity to mint |
_update
Internal function handling token transfers, mints, and burns.
Enforces pause state and validates transfers. No receiver callbacks in ERC-6909.
Notes:
-
throws: InvalidSelfTransfer When from equals to
-
throws: InvalidZeroValueTransfer When amount is zero
function _update(address from, address to, uint256 id, uint256 amount)
internal
virtual
override
whenNotPaused
notFrozen(from)
notFrozen(to)
tokenExists(id)
tokenTransferable(from, to, id);
Parameters
Name | Type | Description |
---|---|---|
from | address | Source address (zero address for minting) |
to | address | Destination address (zero address for burning) |
id | uint256 | Token type identifier |
amount | uint256 | Quantity to transfer |