ColleCollection
This contract represents a collection of unique tokens (NFTs) which mirror physical assets and extends ERC721 with additional functionality.
The contract is using OpenZeppelin contracts for most of the ERC721 functionality and has extra functions for additional needs.
nextTokenId
uint256 nextTokenId
tokenSaleMetadataIPFS
mapping(uint256 => string) tokenSaleMetadataIPFS
constructor
constructor(string _name, string _symbol) public
Construct a new NFT collection contract.
Parameters
_name
string
The name of the token.
_symbol
string
The symbol of the token.
onlyOwnerApprovedEOAOrVault
modifier onlyOwnerApprovedEOAOrVault(uint256 _tokenId)
Guards ERC721 transfers to the token owner (EOA or contract), approved EOA or approved Vault.
Restricts approved non-vault contracts from transferring tokens to break 3rd party transfers of mirrored assets.
Parameters
_tokenId
uint256
The token id to guard against.
mint
function mint(string _uri, address _receiver) public
Mints a new token.
This function can only be called by a Colle.
Parameters
_uri
string
The token URI.
_receiver
address
The address that will receive the minted token.
updateSaleMetadata
function updateSaleMetadata(uint256 _tokenId, string _ipfsHash) public
Updates the sale metadata for a token.
This function can only be called by a Colle or the owner of the token.
Parameters
_tokenId
uint256
The ID of the token to update.
_ipfsHash
string
The new IPFS hash for the token metadata.
getSaleMetadata
function getSaleMetadata(uint256 _tokenId) public view returns (string)
Returns the sale metadata for a token.
Parameters
_tokenId
uint256
The ID of the token to query.
Return Values
[0]
string
The IPFS hash of the sale metadata.
isSaleMetadataSet
function isSaleMetadataSet(uint256 _tokenId) public view returns (bool)
Checks if sale metadata is set for a token.
Parameters
_tokenId
uint256
The ID of the token to check.
Return Values
[0]
bool
True if the token has sale metadata set, false otherwise.
permitApprove
function permitApprove(address _to, uint256 _tokenId, struct Signature _signature) public
Approves an address to transfer a specific token.
Parameters
_to
address
The address to approve.
_tokenId
uint256
The ID of the token to approve.
_signature
struct Signature
The signature from the approving address, the 'from', including deadline
permitSetApprovalForAll
function permitSetApprovalForAll(address _operator, bool _approve, struct Signature _signature) public
Approves an address to transfer any tokens owned by the sender.
Parameters
_operator
address
The address to approve.
_approve
bool
Whether to approve or revoke approval
_signature
struct Signature
The signature, deadline and signer from the owner of the token.
permitSafeTransfer
function permitSafeTransfer(address _to, uint256 _tokenId, struct Signature _signature) public
Transfers a token from one address to another, verifying the validity of a signature.
Parameters
_to
address
The address to receive the token.
_tokenId
uint256
The ID of the token to transfer.
_signature
struct Signature
The signature, deadline and signer from the owner of the token.
getNextTokenId
function getNextTokenId() public view returns (uint256)
Returns the ID of the next token that will be minted.
Return Values
[0]
uint256
The ID of the next token.
supportsInterface
function supportsInterface(bytes4 _interfaceId) public view virtual returns (bool)
Checks if the contract implements an interface.
Parameters
_interfaceId
bytes4
The ID of the interface.
Return Values
[0]
bool
True if the contract implements the interface, false otherwise.
transferFrom
function transferFrom(address _from, address _to, uint256 _tokenId) public virtual
Transfers a token from one address to another.
In order to prevent mirrored assets from being traded on 3rd party markets, only direct transfer or Marketplace vault transfer cause call transferFrom.
Parameters
_from
address
The current owner of the token.
_to
address
The address to receive the token.
_tokenId
uint256
The ID of the token to transfer.
safeTransferFrom
function safeTransferFrom(address _from, address _to, uint256 _tokenId) public virtual
Safely transfers a token from one address to another.
In order to prevent mirrored assets from being traded on 3rd party markets, only direct transfer or Marketplace vault transfer cause call safeTransferFrom.
Parameters
_from
address
The current owner of the token.
_to
address
The address to receive the token.
_tokenId
uint256
The ID of the token to transfer.
safeTransferFrom
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes _data) public virtual
Safely transfers a token from one address to another.
In order to prevent mirrored assets from being traded on 3rd party markets, only direct transfer or Marketplace vault transfer cause call safeTransferFrom.
Parameters
_from
address
The current owner of the token.
_to
address
The address to receive the token.
_tokenId
uint256
The ID of the token to transfer.
_data
bytes
Additional data with no specified format.
_getPermitApproveHash
function _getPermitApproveHash(struct Signature _signature, address _to, uint256 _tokenId) internal view virtual returns (bytes32)
Internal function to get the expected EIP-712 signed hash to permit approving a token transfer
Parameters
_signature
struct Signature
The signature, deadline and signer from the owner of the token.
_to
address
The address to approve.
_tokenId
uint256
The ID of the token to approve.
_getPermitSetApprovalForAllHash
function _getPermitSetApprovalForAllHash(struct Signature _signature, address _operator, bool _approve) internal view virtual returns (bytes32)
Internal function to get the expected EIP-712 signed hash to permit approving a token transfer
Parameters
_signature
struct Signature
The signature, deadline and signer from the owner of the tokens.
_operator
address
The address to approve.
_approve
bool
Whether to approve or revoke approval
_getPermitSafeTransferHash
function _getPermitSafeTransferHash(struct Signature _signature, address _to, uint256 _tokenId) internal view virtual returns (bytes32)
Internal function to get the expected EIP-712 signed hash to permit transfering a token
Parameters
_signature
struct Signature
The signature, deadline and signer from the owner of the tokens.
_to
address
The address to transfer to.
_tokenId
uint256
The ID of the token to transfer.
Last updated