Closed ghost closed 2 years ago
@noel-yoo should not there be a MintWithUri
transition as well?
@RatulSaha I initially thought a batch operation is enough for a fallback for dynamic or randomized minting with decentalized URIs. We want to keep the standard very minimal if possible.
However, because of the clear event log and the gas saving I included MintWithURI
.
Regarding the gas saving, BatchMintWithURIs
for a single token costs 559
while MintWithURI
would cost 541
(-3.32%
).
The solution should be consistent and minimal without creating additional complexity if possible.
The initial approach was having a minimal fallback. But It will make this standard inconsistent and more complex to have BatchMintWithURIs
(and MintWithURI
) as there will be 3 (or 4) transitions for minting.
Considering this use case https://blog.chain.link/build-deploy-and-sell-your-own-dynamic-nft, the standard needs to be more flexible for token URIs such that it can support dynamic or randomized minting.
Therefore, I've changed the Mint
and BatchMint
to take the token_uri
parameter where token_uri
can be empty string.
Mint(to: ByStr20, token_uri: String)
BatchMint(to_token_uri_pair_list: List (Pair ByStr20 String))
If you want to use the concatenated URI to save gas cost, pass an empty string for token URI when minting. In this case, the token_uri
field doesn't get mutated. Also, you need to initialize base_uri
when contract is created.
If you need dynamic or randomized minting with decentalized URIs, pass a specific token URI per token when minting.
For anyone coming later (and maybe hint at this at the standard, @noel-yoo) — this approach also works for hybrid use case. In the same contract, some tokens can be supplied with a token URI, while others have a base URI. This is not exactly recommended for standard use cases, but since the token URI takes precedence over the base URI per token, this is possible for those who may want to.
This makes me a bit confused,
Is it still required to have a base_uri that returns the correct metadata for that nft or are you allowed to have a token_uri which takes presedence over
Is this only to be compatible with ERC721?
If I want to fetch metadata am I supposed to have to fetch both base_uri and token_uri substate?
@Hatzz
Each token can use either it's own specific token URI or <base_uri><token_id>
.
<base_uri><token_id>
as token URIThis case, the tokens are minted without token URI by Mint
or BatchMint
. Therefore, there is no specific URI in token_uris
field. token_uris
field can is an empty map since every token uses <base_uri><token_id>
.
e.g.
The base URI: https://creatures-api.zilliqa.com/api/creature/
token URIs:
https://creatures-api.zilliqa.com/api/creature/1
https://creatures-api.zilliqa.com/api/creature/2
https://creatures-api.zilliqa.com/api/creature/3
<base_uri><token_id>
as token URI.This case, the tokens are minted with token URI by Mint
or BatchMint
. Therefore, there are specific URIs in token_uris
field. The base_uri
field can be an empty string since every token has its own token URI.
e.g. The base URI: empty string token URIs:
https://ipfs.zilliqa.com/ipfs/1me7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pY0000ZILX
https://ipfs.zilliqa.com/ipfs/2me7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pY0000ZILY
https://ipfs.zilliqa.com/ipfs/3me7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pY0000ZILZ
<base_uri><token_id>
as token URI and some have their own token URI.This case is a mix of case 1 and case 2. Both base_uri
and token_uris
field are used. base_uri
shouldn't an empty string and token_uris
shouldn't be an empty map.
The base URI: https://creatures-api.zilliqa.com/api/creature/
token URIs:
https://creatures-api.zilliqa.com/api/creature/1
https://creatures-api.zilliqa.com/api/creature/2
https://ipfs.zilliqa.com/ipfs/1me7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pY0000ZIL0
To get a token URI for a token, do:
<base_uri><token_id>
.@noel-yoo can you check https://github.com/Zilliqa/ZRC/pull/119/commits/3842e1e63c7da990a53a6e374e344b940a1affdb
rebase
@noel-yoo Thanks for the reply! Do you think this should be written in the documentation somewhere maybe?
I have updated the field description for base_uri and token_uris.
Description
This PR supports special use cases with decentralized metadata URIs in ZRC-6.
markdown
References: