Skip to content

Instantly share code, notes, and snippets.

@prajwolrg
Created November 1, 2022 14:58
Show Gist options
  • Save prajwolrg/3daabe61f1cf98243ceb58fcaad1b58d to your computer and use it in GitHub Desktop.
Save prajwolrg/3daabe61f1cf98243ceb58fcaad1b58d to your computer and use it in GitHub Desktop.
Add new resource to the NFT
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