This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.5.0; | |
| // Mapping from owner to list of owned token IDs | |
| mapping(address => uint256[]) private _ownedTokens; | |
| // Mapping from token ID to index of the owner tokens list | |
| mapping(uint256 => uint256) private _ownedTokensIndex; | |
| // Array with all token ids, used for enumeration | |
| uint256[] private _allTokens; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.5.0; | |
| function _mint(address to, uint256 tokenId) internal { | |
| _tokenOwner[tokenId] = to; | |
| _ownedTokensCount[to].increment(); | |
| } | |
| function _burn(address owner, uint256 tokenId) internal { | |
| _ownedTokensCount[owner].decrement(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.5.0; | |
| // Mapping from token ID to approved address | |
| mapping (uint256 => address) private _tokenApprovals; | |
| function approve(address to, uint256 tokenId) public { | |
| address owner = ownerOf(tokenId); | |
| require(to != owner, "ERC721: approval to current owner"); | |
| require(msg.sender == owner || isApprovedForAll(owner, msg.sender), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.5.0; | |
| function transferFrom(address from, address to, uint256 tokenId) public { | |
| // ... | |
| _ownedTokensCount[from].decrement(); | |
| _ownedTokensCount[to].increment(); | |
| _tokenOwner[tokenId] = to; | |
| // ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.5.0; | |
| // Mapping from token ID to owner | |
| mapping (uint256 => address) private _tokenOwner; | |
| // Mapping from owner to number of owned token | |
| mapping (address => Counters.Counter) private _ownedTokensCount; | |
| function balanceOf(address owner) public view returns (uint256) { | |
| require(owner != address(0), "ERC721: balance query for the zero address"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.4.20; | |
| interface ERC721 { | |
| function name() public view returns (string); | |
| function symbol() public view returns (string); | |
| function tokenURI(uint256 _tokenId) public view returns (string); | |
| function totalSupply() public view returns (uint256); | |
| function tokenByIndex(uint256 _index) public view returns (uint256); | |
| function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| *Submitted for verification at Etherscan.io on 2020-12-12 | |
| */ | |
| // File contracts/libs/IERC165.sol | |
| // File: openzeppelin-solidity/contracts/introspection/IERC165.sol | |
| pragma solidity ^0.5.0; | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// @title A 6x6 chess engine with negamax search | |
| /// @author fiveoutofnine | |
| /// @notice Docstrings below are written from the perspective of black (i.e. written as if the | |
| /// engine is always black). However, due to negamax's symmetric nature, the engine may be used for | |
| /// white as well. | |
| contract Engine { | |
| using Chess for uint256; | |
| using Engine for uint256; | |
| /// @notice Searches for the ``best'' move. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// @title A library that generates HTML art for fiveoutofnine (an on-chain 6x6 chess engine) | |
| /// The art is generated as HTML code with in-line CSS (0 JS) | |
| contract fiveoutofnineART { | |
| /// @notice Takes in data for a given fiveoutofnine NFT and outputs its metadata in JSON form. | |
| /// @param _internalId A bitpacked uint256 where the first 128 bits are the game ID, and the | |
| /// last 128 bits are the move ID within the game. | |
| /// @param _move A struct with information about the player's move and engine's response (see | |
| /// {Chess-Move}). | |
| /// @return Base 64-encoded JSON of metadata generated from `_internalId` and `_move`. | |
| function getMetadata(uint256 _internalId, Chess.Move memory _move) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract Example { | |
| function playMove(uint256 _board) internal { | |
| uint256 rotated = _board.rotate(); | |
| // ... | |
| } | |
| } |