OwnershipNFTs
Inherits: IERC721Metadata, IERC165
State Variables
SEAWATER
ISeawaterAMM public immutable SEAWATER;
TOKEN_URI
TOKEN_URI to set as the default token URI for every NFT
immutable in practice (not set anywhere)
string public TOKEN_URI;
name
name of the NFT, set by the constructor
string public name;
symbol
symbol of the NFT, set during the constructor
string public symbol;
getApproved_
getApproved that can spend the id of the tokens given
required in the NFT spec and we simplify the use here by naming the storage slot as such
mapping(uint256 => address) private getApproved_;
isApprovedForAll
Query if an address is an authorized operator for another address
mapping(address => mapping(address => bool)) public isApprovedForAll;
Functions
constructor
constructor(string memory _name, string memory _symbol, string memory _tokenURI, ISeawaterAMM _seawater);
ownerOf
Find the owner of an NFT
NFTs assigned to zero address are considered invalid, and queries about them do throw.
function ownerOf(uint256 _tokenId) public view returns (address);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The identifier for an NFT |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The address of the owner of the NFT |
getApproved
Get the approved address for a single NFT
Throws if _tokenId
is not a valid NFT.
function getApproved(uint256 _tokenId) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The NFT to find the approved address for |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The approved address for this NFT, or the zero address if there is none |
_onTransferReceived
_onTransferReceived by calling the callback onERC721Received
in the recipient if they have codesize > 0. if the callback
doesn't return the selector, revert!
function _onTransferReceived(address _sender, address _from, address _to, uint256 _tokenId) internal;
Parameters
Name | Type | Description |
---|---|---|
_sender | address | that did the transfer |
_from | address | owner of the NFT that the sender is transferring |
_to | address | recipient of the NFT that we're calling the function on |
_tokenId | uint256 | that we're transferring from our internal storage |
_requireAuthorised
function _requireAuthorised(address _from, uint256 _tokenId) internal view;
_transfer
function _transfer(address _from, address _to, uint256 _tokenId) internal;
transferFrom
Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
TO CONFIRM THAT _to
IS CAPABLE OF RECEIVING NFTS OR ELSE
THEY MAY BE PERMANENTLY LOST
Throws unless msg.sender
is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from
is
not the current owner. Throws if _to
is the zero address. Throws if
_tokenId
is not a valid NFT.
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
Parameters
Name | Type | Description |
---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender
is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from
is
not the current owner. Throws if _to
is the zero address. Throws if
_tokenId
is not a valid NFT. When transfer is complete, this function
checks if _to
is a smart contract (code size > 0). If so, it calls
onERC721Received
on _to
and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))
.
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
Parameters
Name | Type | Description |
---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender
is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from
is
not the current owner. Throws if _to
is the zero address. Throws if
_tokenId
is not a valid NFT. When transfer is complete, this function
checks if _to
is a smart contract (code size > 0). If so, it calls
onERC721Received
on _to
and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))
.
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata) external payable;
Parameters
Name | Type | Description |
---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
<none> | bytes |
approve
Change or reaffirm the approved address for an NFT
The zero address indicates there is no approved address.
Throws unless msg.sender
is the current NFT owner, or an authorized
operator of the current owner.
function approve(address _approved, uint256 _tokenId) external payable;
Parameters
Name | Type | Description |
---|---|---|
_approved | address | The new approved NFT controller |
_tokenId | uint256 | The NFT to approve |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage
all of msg.sender
's assets
Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
function setApprovalForAll(address _operator, bool _approved) external;
Parameters
Name | Type | Description |
---|---|---|
_operator | address | Address to add to the set of authorized operators |
_approved | bool | True if the operator is approved, false to revoke approval |
balanceOf
Count all NFTs assigned to an owner
NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.
function balanceOf(address _spender) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_spender | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The number of NFTs owned by _owner , possibly zero |
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId
is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256) external view returns (string memory);
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) external pure 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 |