TokenTransferable
Inherits: ContextUpgradeable
Author: EVMAuth
Manages token transferability settings for soulbound functionality.
Abstract contract enabling tokens to be marked as non-transferable (i.e. "soulbound"). Uses EIP-7201 storage pattern for upgrade safety.
State Variables
TokenTransferableStorageLocation
EIP-7201 storage slot for TokenTransferable state.
Computed as: keccak256(abi.encode(uint256(keccak256("tokentransferable.storage.TokenTransferable")) - 1)) & ~bytes32(uint256(0xff)). Prevents storage collisions in upgradeable contracts.
bytes32 private constant TokenTransferableStorageLocation =
0xdaa3d1cf82c71b982a9e24ff7dadd71a10e8c3e82a219c0e60ca5c6b8e617700;
Functions
_getTokenTransferableStorage
Retrieves the storage struct for TokenTransferable.
Internal function using inline assembly for direct storage access.
function _getTokenTransferableStorage() private pure returns (TokenTransferableStorage storage $);
Returns
Name | Type | Description |
---|---|---|
$ | TokenTransferableStorage | Storage pointer to TokenTransferableStorage struct |
tokenTransferable
Validates single token transferability.
Modifier allowing mints/burns but blocking transfers of soulbound tokens. Apply to single-token transfer functions like ERC6909's _update
Note: throws: TokenIsNonTransferable When attempting to transfer soulbound token
modifier tokenTransferable(address from, address to, uint256 id);
Parameters
Name | Type | Description |
---|---|---|
from | address | Source address (zero for mints) |
to | address | Destination address (zero for burns) |
id | uint256 | Token type identifier to check |
allTokensTransferable
Validates batch token transferability.
Modifier allowing mints/burns but blocking transfers of soulbound tokens. Apply to batch transfer functions like ERC1155's _update.
Note: throws: TokenIsNonTransferable When any token in batch is soulbound
modifier allTokensTransferable(address from, address to, uint256[] memory ids);
Parameters
Name | Type | Description |
---|---|---|
from | address | Source address (zero for mints) |
to | address | Destination address (zero for burns) |
ids | uint256[] | Array of token type identifiers to check |
__TokenTransferable_init
Internal initializer for TokenTransferable setup.
Currently empty as no initialization needed.
function __TokenTransferable_init() internal onlyInitializing;
__TokenTransferable_init_unchained
Unchained initializer for contract-specific storage.
Currently empty but reserved for future initialization.
function __TokenTransferable_init_unchained() internal onlyInitializing;
isTransferable
Checks if token type allows transfers.
Returns transferability status.
function isTransferable(uint256 id) public view virtual returns (bool);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | Token type identifier |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if transferable, false if soulbound |
_setTransferable
Internal function to configure token transferability.
Sets whether token type is transferable or soulbound.
function _setTransferable(uint256 id, bool transferable) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | Token type identifier |
transferable | bool | True for transferable, false for soulbound |
Errors
TokenIsNonTransferable
Error for transfer attempts on soulbound tokens.
error TokenIsNonTransferable(uint256 id);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | Token type identifier that is non-transferable |
Structs
TokenTransferableStorage
Note: storage-location: erc7201:tokentransferable.storage.TokenTransferable
struct TokenTransferableStorage {
mapping(uint256 => bool) transferable;
}