OwnershipNFTs

Git Source

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

NameTypeDescription
_tokenIduint256The identifier for an NFT

Returns

NameTypeDescription
<none>addressThe 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

NameTypeDescription
_tokenIduint256The NFT to find the approved address for

Returns

NameTypeDescription
<none>addressThe 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

NameTypeDescription
_senderaddressthat did the transfer
_fromaddressowner of the NFT that the sender is transferring
_toaddressrecipient of the NFT that we're calling the function on
_tokenIduint256that 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

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The 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

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The 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

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The 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

NameTypeDescription
_approvedaddressThe new approved NFT controller
_tokenIduint256The 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

NameTypeDescription
_operatoraddressAddress to add to the set of authorized operators
_approvedboolTrue 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

NameTypeDescription
_spenderaddress

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
_interfaceIdbytes4

Returns

NameTypeDescription
<none>booltrue if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise