Created
January 21, 2022 14:13
-
-
Save m1guelpf/1d1682abb6fa3fab9f600768f26afa0a to your computer and use it in GitHub Desktop.
This file contains 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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.10; | |
import 'solmate/tokens/ERC721.sol'; | |
contract NFTBillboard is ERC721('NFT Billboard', 'BNFT') { | |
error Unauthorized(); | |
error TokenNotFound(); | |
struct NFT { | |
ERC721 tokenContract; | |
uint256 tokenId; | |
} | |
mapping(uint256 => NFT) getBillboard; | |
constructor() { | |
for (uint256 i = 1; i < 10; i++) { | |
_mint(msg.sender, i); | |
} | |
} | |
function updateBillboard(uint256 id, NFT memory newToken) public payable { | |
if (ownerOf[id] != msg.sender) revert Unauthorized(); | |
getBillboard[id] = newToken; | |
} | |
function tokenURI(uint256 id) public view override returns (string memory) { | |
NFT memory nft = getBillboard[id]; | |
if (address(nft.tokenContract) == address(0)) revert TokenNotFound(); | |
return nft.tokenContract.tokenURI(nft.tokenId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment