Skip to main content

MockERC721

Git Source

Inherits: IERC721Metadata

This is a mock contract of the ERC721 standard for testing purposes only, it SHOULD NOT be used in production.

Forked from: https://github.com/transmissions11/solmate/blob/0384dbaaa4fcb5715738a9254a7c0a4cb62cf458/src/tokens/ERC721.sol

State Variables

_name

string internal _name;

_symbol

string internal _symbol;

_ownerOf

mapping(uint256 => address) internal _ownerOf;

_balanceOf

mapping(address => uint256) internal _balanceOf;

_getApproved

mapping(uint256 => address) internal _getApproved;

_isApprovedForAll

mapping(address => mapping(address => bool)) internal _isApprovedForAll;

initialized

A bool to track whether the contract has been initialized.

bool private initialized;

Functions

name

function name() external view override returns (string memory);

symbol

function symbol() external view override returns (string memory);

tokenURI

function tokenURI(uint256 id) public view virtual override returns (string memory);

ownerOf

function ownerOf(uint256 id) public view virtual override returns (address owner);

balanceOf

function balanceOf(address owner) public view virtual override returns (uint256);

getApproved

function getApproved(uint256 id) public view virtual override returns (address);

isApprovedForAll

function isApprovedForAll(address owner, address operator) public view virtual override returns (bool);

initialize

To hide constructor warnings across solc versions due to different constructor visibility requirements and syntaxes, we add an initialization function that can be called only once.

function initialize(string memory name_, string memory symbol_) public;

approve

function approve(address spender, uint256 id) public payable virtual override;

setApprovalForAll

function setApprovalForAll(address operator, bool approved) public virtual override;

transferFrom

function transferFrom(address from, address to, uint256 id) public payable virtual override;

safeTransferFrom

function safeTransferFrom(address from, address to, uint256 id) public payable virtual override;

safeTransferFrom

function safeTransferFrom(address from, address to, uint256 id, bytes memory data) public payable virtual override;

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);

_mint

function _mint(address to, uint256 id) internal virtual;

_burn

function _burn(uint256 id) internal virtual;

_safeMint

function _safeMint(address to, uint256 id) internal virtual;

_safeMint

function _safeMint(address to, uint256 id, bytes memory data) internal virtual;

_isContract

function _isContract(address _addr) private view returns (bool);