ERC1155TL
Inherits: ERC1155Upgradeable, EIP2981TLUpgradeable, OwnableAccessControlUpgradeable, ICreatorBase, IERC1155TL, IStory
Author: transientlabs.xyz
Sovereign ERC-1155 Creator Contract with Story Inscriptions
State Variables
VERSION
String representation for address
string public constant VERSION = "3.0.1";
ADMIN_ROLE
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
APPROVED_MINT_CONTRACT
bytes32 public constant APPROVED_MINT_CONTRACT = keccak256("APPROVED_MINT_CONTRACT");
_counter
uint256 private _counter;
name
string public name;
symbol
string public symbol;
storyEnabled
bool public storyEnabled;
blocklistRegistry
IBlockListRegistry public blocklistRegistry;
_tokens
mapping(uint256 => Token) private _tokens;
Functions
constructor
constructor(bool disable);
Parameters
Name | Type | Description |
---|---|---|
disable | bool | Boolean to disable initialization for the implementation contract |
initialize
tx.origin
is used in the events here as these can be deployed via contract factories and we want to capture the true sender
function initialize(
string memory name_,
string memory symbol_,
string memory personalization,
address defaultRoyaltyRecipient,
uint256 defaultRoyaltyPercentage,
address initOwner,
address[] memory admins,
bool enableStory,
address initBlockListRegistry
) external initializer;
Parameters
Name | Type | Description |
---|---|---|
name_ | string | The name of the 721 contract |
symbol_ | string | The symbol of the 721 contract |
personalization | string | A string to emit as a collection story. Can be ASCII art or something else that is a personalization of the contract. |
defaultRoyaltyRecipient | address | The default address for royalty payments |
defaultRoyaltyPercentage | uint256 | The default royalty percentage of basis points (out of 10,000) |
initOwner | address | The owner of the contract |
admins | address[] | Array of admin addresses to add to the contract |
enableStory | bool | A bool deciding whether to add story fuctionality or not |
initBlockListRegistry | address | Address of the blocklist registry to use |
totalSupply
Function to get total supply minted so far
function totalSupply() external view returns (uint256);
getTokenDetails
Function to get token creation details
function getTokenDetails(uint256 tokenId) external view returns (Token memory);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token to lookup |
setApprovedMintContracts
Function to set approved mint contracts
Access to owner or admin
function setApprovedMintContracts(address[] calldata minters, bool status) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
minters | address[] | Array of minters to grant approval to |
status | bool | Status for the minters |
createToken
Function to create a token that can be minted to creator or airdropped
Requires owner or admin
function createToken(string calldata newUri, address[] calldata addresses, uint256[] calldata amounts)
external
onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
newUri | string | The uri for the token to create |
addresses | address[] | The addresses to mint the new token to |
amounts | uint256[] | The amount of the new token to mint to each address |
createToken
Function to create a token that can be minted to creator or airdropped
Requires owner or admin
function createToken(
string calldata newUri,
address[] calldata addresses,
uint256[] calldata amounts,
address royaltyAddress,
uint256 royaltyPercent
) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
newUri | string | The uri for the token to create |
addresses | address[] | The addresses to mint the new token to |
amounts | uint256[] | The amount of the new token to mint to each address |
royaltyAddress | address | |
royaltyPercent | uint256 |
batchCreateToken
function to batch create tokens that can be minted to creator or airdropped
requires owner or admin
function batchCreateToken(string[] calldata newUris, address[][] calldata addresses, uint256[][] calldata amounts)
external
onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
newUris | string[] | the uris for the tokens to create |
addresses | address[][] | 2d dynamic array holding the addresses to mint the new tokens to |
amounts | uint256[][] | 2d dynamic array holding the amounts of the new tokens to mint to each address |
batchCreateToken
function to batch create tokens that can be minted to creator or airdropped
requires owner or admin
function batchCreateToken(
string[] calldata newUris,
address[][] calldata addresses,
uint256[][] calldata amounts,
address[] calldata royaltyAddresses,
uint256[] calldata royaltyPercents
) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
newUris | string[] | the uris for the tokens to create |
addresses | address[][] | 2d dynamic array holding the addresses to mint the new tokens to |
amounts | uint256[][] | 2d dynamic array holding the amounts of the new tokens to mint to each address |
royaltyAddresses | address[] | |
royaltyPercents | uint256[] |
mintToken
Function to mint existing token to recipients
Requires owner or admin
function mintToken(uint256 tokenId, address[] calldata addresses, uint256[] calldata amounts)
external
onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token to mint |
addresses | address[] | The addresses to mint to |
amounts | uint256[] | Amounts of the token to mint to each address |
externalMint
External mint function
Requires caller to be an approved mint contract
function externalMint(uint256 tokenId, address[] calldata addresses, uint256[] calldata amounts)
external
onlyRole(APPROVED_MINT_CONTRACT);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token to mint |
addresses | address[] | The addresses to mint to |
amounts | uint256[] | Amounts of the token to mint to each address |
burn
Function to burn tokens from an account
Msg.sender must be token owner or operator
function burn(address from, uint256[] calldata tokenIds, uint256[] calldata amounts) external;
Parameters
Name | Type | Description |
---|---|---|
from | address | Address to burn from |
tokenIds | uint256[] | Array of tokens to burn |
amounts | uint256[] | Amount of each token to burn |
setDefaultRoyalty
Function to set the default royalty specification
Requires owner or admin
function setDefaultRoyalty(address newRecipient, uint256 newPercentage) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
newRecipient | address | The new royalty payout address |
newPercentage | uint256 | The new royalty percentage in basis (out of 10,000) |
setTokenRoyalty
Function to override a token's royalty info
Requires owner or admin
function setTokenRoyalty(uint256 tokenId, address newRecipient, uint256 newPercentage)
external
onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token to override royalty for |
newRecipient | address | The new royalty payout address for the token id |
newPercentage | uint256 | The new royalty percentage in basis (out of 10,000) for the token id |
setTokenUri
Function to set a token uri
Requires owner or admin
function setTokenUri(uint256 tokenId, string calldata newUri) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token to mint |
newUri | string | The new token uri |
uri
function uri(uint256 tokenId) public view override(ERC1155Upgradeable) returns (string memory);
addCollectionStory
Function to let the creator add a story to the collection they have created
Depending on the implementation, this function may be restricted in various ways, such as limiting the number of times the creator may write a story.
function addCollectionStory(string calldata, string calldata story) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
<none> | string | |
story | string | The story written and attached to the token id |
addCreatorStory
Function to let the creator add a story to any token they have created
Depending on the implementation, this function may be restricted in various ways, such as limiting the number of times the creator may write a story.
function addCreatorStory(uint256 tokenId, string calldata, string calldata story)
external
onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token id to which the story is attached |
<none> | string | |
story | string | The story written and attached to the token id |
addStory
Function to let collectors add a story to any token they own
Depending on the implementation, this function may be restricted in various ways, such as limiting the number of times a collector may write a story.
function addStory(uint256 tokenId, string calldata, string calldata story) external;
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token id to which the story is attached |
<none> | string | |
story | string | The story written and attached to the token id |
setStoryStatus
Function to enable or disable collector story inscriptions
Requires owner or admin
function setStoryStatus(bool status) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
status | bool | The status to set for collector story inscriptions |
setBlockListRegistry
Function to change the blocklist registry
Access to owner or admin
function setBlockListRegistry(address newBlockListRegistry) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
newBlockListRegistry | address | The new blocklist registry |
setApprovalForAll
function setApprovalForAll(address operator, bool approved) public override(ERC1155Upgradeable);
tlNftDelegationRegistry
Function to get the delegation registry
function tlNftDelegationRegistry() external pure returns (ITLNftDelegationRegistry);
setNftDelegationRegistry
Function to change the TL NFT delegation registry
Access to owner or admin
function setNftDelegationRegistry(address) external pure;
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
supportsInterface
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC1155Upgradeable, EIP2981TLUpgradeable)
returns (bool);
_exists
Private helper function to verify a token exists
function _exists(uint256 tokenId) private view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token to check existence for |
_createToken
Private helper function to create a new token
function _createToken(string memory newUri, address[] memory addresses, uint256[] memory amounts)
private
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
newUri | string | The uri for the token to create |
addresses | address[] | The addresses to mint the new token to |
amounts | uint256[] | The amount of the new token to mint to each address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 Token id created |
_mintToken
Private helper function
function _mintToken(uint256 tokenId, address[] calldata addresses, uint256[] calldata amounts) private;
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token to mint |
addresses | address[] | The addresses to mint to |
amounts | uint256[] | Amounts of the token to mint to each address |
_isOperatorBlocked
function _isOperatorBlocked(address operator) internal view returns (bool);
Errors
EmptyTokenURI
Token uri is an empty string
error EmptyTokenURI();
BatchSizeTooSmall
Batch size too small
error BatchSizeTooSmall();
MintToZeroAddresses
Mint to zero addresses
error MintToZeroAddresses();
ArrayLengthMismatch
Array length mismatch
error ArrayLengthMismatch();
CallerNotTokenOwner
Token not owned by the owner of the contract
error CallerNotTokenOwner();
CallerNotApprovedOrOwner
Caller is not approved or owner
error CallerNotApprovedOrOwner();
TokenDoesntExist
Token does not exist
error TokenDoesntExist();
BurnZeroTokens
Burning zero tokens
error BurnZeroTokens();
OperatorBlocked
Operator for token approvals blocked
error OperatorBlocked();
StoryNotEnabled
Story not enabled for collectors
error StoryNotEnabled();