Shatter
Inherits: ERC721Upgradeable, EIP2981TLUpgradeable, OwnableAccessControlUpgradeable, IShatter, ICreatorBase, ISynergy, IStory, IERC4906
Author: transientlabs.xyz
Sovereign Shatter Creator Contract with Synergy and Story Inscriptions
State Variables
VERSION
string representation of uint256
String representation for address
string public constant VERSION = "3.1.0";
ADMIN_ROLE
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
isShattered
bool public isShattered;
isFused
bool public isFused;
storyEnabled
bool public storyEnabled;
tlNftDelegationRegistry
ITLNftDelegationRegistry public tlNftDelegationRegistry;
blocklistRegistry
IBlockListRegistry public blocklistRegistry;
minShatters
uint128 public minShatters;
maxShatters
uint128 public maxShatters;
shatters
uint128 public shatters;
shatterTime
uint256 public shatterTime;
_shatterAddress
address private _shatterAddress;
_baseUri
string private _baseUri;
_proposedTokenUris
mapping(uint256 => string) private _proposedTokenUris;
_tokenUris
mapping(uint256 => string) private _tokenUris;
Functions
constructor
constructor(bool disable);
Parameters
Name | Type | Description |
---|---|---|
disable | bool | Boolean to disable initialization for the implementation contract |
initialize
function initialize(
string memory name,
string memory symbol,
string memory personalization,
address defaultRoyaltyRecipient,
uint256 defaultRoyaltyPercentage,
address initOwner,
address[] memory admins,
bool enableStory,
address initBlockListRegistry,
address initNftDelegationRegistry
) 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 |
initNftDelegationRegistry | address | Address of the TL nft delegation registry to use |
totalSupply
function to get total supply of tokens on the contract
function totalSupply() external view returns (uint256);
setApprovedMintContracts
Function to set approved mint contracts
Access to owner or admin
function setApprovedMintContracts(address[] calldata, bool) external pure;
Parameters
Name | Type | Description |
---|---|---|
<none> | address[] | |
<none> | bool |
mint
Function for minting the 1/1
Requires contract owner or admin
function mint(address recipient, string memory uri, uint128 min, uint128 max, uint256 time)
external
onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
recipient | address | The address to mint to token to |
uri | string | The base uri to be used for the shatter folder WITHOUT trailing "/" |
min | uint128 | The minimum number of shatters |
max | uint128 | The maximum number of shatters |
time | uint256 | Time after which shatter can occur |
shatter
function to shatter the 1/1 token
*care should be taken to ensure that the following conditions are met
- this function can only be called once
- msg.sender actually owns the 1/1 token
- the token has not been shattered yet
- block.timestamp is past the shatter time (if applicable)
- numShatters is an allowed value as set by the creator*
function shatter(uint128 numShatters) external;
Parameters
Name | Type | Description |
---|---|---|
numShatters | uint128 | is the total number of shatters to make |
fuse
function to fuse shatters back into a 1/1
*care should be taken to ensure that the following conditions are met
- this function can only be called once
- the 1/1 is actually shattered
- msg.sender actually owns all of the shatters*
function fuse() external;
setDefaultRoyalty
function to set the default royalty specification
requires owner
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
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 |
proposeNewTokenUri
function to propose a token uri update for a specific token
requires owner
if the owner of the contract is the owner of the token, the change takes hold right away
function proposeNewTokenUri(uint256 tokenId, string calldata newUri) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | the token to propose new metadata for |
newUri | string | the new token uri proposed |
acceptTokenUriUpdate
function to accept a proposed token uri update for a specific token
requires owner of the token to call the function
function acceptTokenUriUpdate(uint256 tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | the token to accept the metadata update for |
rejectTokenUriUpdate
function to reject a proposed token uri update for a specific token
requires owner of the token to call the function
function rejectTokenUriUpdate(uint256 tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | the token to reject the metadata update for |
tokenURI
See {IERC721Metadata-tokenURI}.
function tokenURI(uint256 tokenId) public view override(ERC721Upgradeable) 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 |
approve
See {IERC721-approve}.
function approve(address to, uint256 tokenId) public override(ERC721Upgradeable, IERC721);
setApprovalForAll
See {IERC721-setApprovalForAll}.
function setApprovalForAll(address operator, bool approved) public override(ERC721Upgradeable, IERC721);
setNftDelegationRegistry
Function to change the TL NFT delegation registry
Access to owner or admin
function setNftDelegationRegistry(address newNftDelegationRegistry) external onlyRoleOrOwner(ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
newNftDelegationRegistry | address | The new blocklist registry |
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
override(ERC721Upgradeable, EIP2981TLUpgradeable, 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 |
_ownerOf
function to override { ERC721Upgradeable._ownerOf } to allow for batch minting/shatter
Returns the owner of the tokenId
. Does NOT revert if token doesn't exist
IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances
consistent with ownership. The invariant to preserve is that for any address a
the value returned by
balanceOf(a)
must be equal to the number of tokens such that _ownerOf(tokenId)
is a
.
function _ownerOf(uint256 tokenId) internal view virtual override returns (address);
_exists
Function to check if a token exists
function _exists(uint256 tokenId) internal view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token id to check |
_isTokenOwnerOrDelegate
Function to get if msg.sender is the token owner or delegated owner
function _isTokenOwnerOrDelegate(uint256 tokenId) internal view returns (bool);
_isOperatorBlocked
function _isOperatorBlocked(address operator) internal view returns (bool);
Errors
EmptyTokenURI
token uri is an empty string
error EmptyTokenURI();
AlreadyMinted
already minted the first token and can't mint another token to this contract
error AlreadyMinted();
NotShattered
not shattered
error NotShattered();
IsShattered
token is shattered
error IsShattered();
IsFused
token is fused
error IsFused();
CallerNotTokenOwner
caller is not the owner of the specific token
error CallerNotTokenOwner();
CallerDoesNotOwnAllTokens
caller does not own all shatters for fusing
error CallerDoesNotOwnAllTokens();
InvalidNumShatters
number shatters requested is invalid
error InvalidNumShatters();
CallPriorToShatterTime
calling shatter prior to shatter time
error CallPriorToShatterTime();
NoTokenUriUpdateAvailable
no proposed token uri to change to
error NoTokenUriUpdateAvailable();
TokenDoesntExist
token does not exist
error TokenDoesntExist();
CallerNotTokenOwnerOrDelegate
Caller is not the owner or delegate of the owner of the specific token
error CallerNotTokenOwnerOrDelegate();
OperatorBlocked
Operator for token approvals blocked
error OperatorBlocked();
StoryNotEnabled
Story not enabled for collectors
error StoryNotEnabled();