Created
November 1, 2022 14:58
-
-
Save prajwolrg/3daabe61f1cf98243ceb58fcaad1b58d to your computer and use it in GitHub Desktop.
Add new resource to the NFT
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
pragma solidity ^0.8.15; | |
function addResourceEntry(string memory metadataURI) | |
external | |
onlyOwnerOrContributor | |
{ | |
unchecked { | |
_totalResources += 1; | |
} | |
_addResourceEntry(uint64(_totalResources), metadataURI); | |
} | |
function _addResourceEntry(uint64 id, string memory metadataURI) internal { | |
if (id == uint64(0)) revert RMRKWriteToZero(); | |
if (bytes(_resources[id]).length > 0) | |
revert RMRKResourceAlreadyExists(); | |
_resources[id] = metadataURI; | |
_allResources.push(id); | |
emit ResourceSet(id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment