Skip to content

SeriesActivation

Handles the activation of ERC1155 tokens through signature verification

Implements ERC1155Holder to receive and hold tokens until activation

uint256 maxTimestampAge

Maximum age of activation timestamp in seconds

contract IERC1155 tokenContract

Token contract this activation contract works with

mapping(uint256 => address) tokenHolders

Mapping of token IDs to their holders (ephemeral addresses)

A zero address means the token has been activated or was never registered

mapping(address => uint256) holderTokenIds

Mapping of holder addresses to their token IDs

Used for reverse lookup during activation

mapping(uint256 => bool) activatedTokens

Mapping to track activated tokens

event TokenHolderRegistered(uint256 tokenId, address holder)

Emitted when a holder is registered for a token

event TokenActivated(uint256 tokenId, address holder, address activator)

Emitted when a token is activated

error InvalidSignature()
error TokenAlreadyActivated()
error TimestampTooOld()
error FutureTimestampNotAllowed()
error TokenNotFound()
error UnregisteredTokenTransfer()
error InvalidTokenContract()
error ZeroAddressNotAllowed()
error TokenAlreadyRegistered()
error HolderNotRegistered()
error EmptyArrays()
error ArrayLengthMismatch()
constructor(address _tokenContract, uint256 _maxTimestampAge) public

Constructor sets the token contract and initial timestamp age

NameTypeDescription
_tokenContractaddressAddress of the ERC1155 token contract
_maxTimestampAgeuint256Maximum age of activation timestamp in seconds
function onERC1155Received(address, address, uint256 id, uint256, bytes) public virtual returns (bytes4)

Override of ERC1155Holder callback to validate token registration

Ensures tokens can only be received if they have a registered holder

function onERC1155BatchReceived(address, address, uint256[] ids, uint256[], bytes) public virtual returns (bytes4)

Override of ERC1155Holder callback to validate batch token registration

Ensures tokens can only be received if they have registered holders

function registerHolder(uint256 tokenId, address holder) external

Register a holder (ephemeral address) for a token

NameTypeDescription
tokenIduint256The ID of the token
holderaddressThe ephemeral address that will be able to sign for activation
function setMaxTimestampAge(uint256 newMaxAge) external

Update the maximum age allowed for activation timestamps

NameTypeDescription
newMaxAgeuint256New maximum age in seconds
function tokenStatus(uint256 tokenId) external view returns (uint8 status)

Get the status of a particular token

NameTypeDescription
tokenIduint256The ID of the token to query
NameTypeDescription
statusuint80 = Valid, 1 = Invalid, 2 = Activated
function activate(uint256 timestamp, bytes signature) external

Activate a token by providing a signature from the registered holder

NameTypeDescription
timestampuint256The timestamp used in the signature
signaturebytesThe signature proving ownership
function registerHolders(uint256[] tokenIds, address[] holders) external

Register multiple holders for tokens in a single transaction

Arrays must be of equal length. Estimated gas cost is ~60k gas per registration. At current block gas limit (~30M), this means practically up to ~400 registrations per tx

NameTypeDescription
tokenIdsuint256[]Array of token IDs to register
holdersaddress[]Array of holder addresses that will be able to sign for activation