Skip to content

Instantly share code, notes, and snippets.

@polluterofminds
Created July 19, 2021 13:40
Show Gist options
  • Save polluterofminds/f1eebbcbc413f0967729a3160d4997ff to your computer and use it in GitHub Desktop.
Save polluterofminds/f1eebbcbc413f0967729a3160d4997ff to your computer and use it in GitHub Desktop.
Minting
export function mint_to(owner_id: AccountId, metadata_uri: MetadataUri): u64 {
const tokenId = storage.getPrimitive<u64>(TOTAL_SUPPLY, 1)
assert(tokenId <= MAX_SUPPLY, ERROR_MAXIMUM_TOKEN_LIMIT_REACHED)
tokenToOwner.set(tokenId, owner_id)
tokenToMetadata.set(tokenId, metadata_uri)
storage.set<u64>(TOTAL_SUPPLY, tokenId + 1)
const owner = storage.get<string>("contract_owner")
assert(owner != null, ERROR_OWNER_ID_DOES_NOT_MATCH_EXPECTATION)
return tokenId
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment