URI schemes โ
Metadata JSON files are referenced using a URI scheme.
The valid URI schemes are:
Prefix | Example | Description |
---|---|---|
http /https | "https://example.com/contract_metadata.json" | Get the file at https://example.com/contract_metadata.json . |
ipfs | "ipfs://QmRbmXcd2yfNVdgHL7oYWS2yd3tztr2NZiqP2LFuw3voPW" | Get the file with the hash QmRbmXcd2yfNVdgHL7oYWS2yd3tztr2NZiqP2LFuw3voPW from IPFS. |
tezos-storage | "tezos-storage://KT1QDFEu8JijYbsJqzoXq7mKvfaQQamHD1kX/foo%2Fhello" | Get the value at the key "foo/hello" from the metadata bigmap of the contract KT1QDFEu8JijYbsJqzoXq7mKvfaQQamHD1kX . |
sha256 | "sha256://0xeaa42ea06b95d7917d22135a630e65352cfd0a721ae88155a1512468a95cb750/https:%2F%2Fexample.com%2contract_metadata.json" | Get the file at https://example.com/contract_metadata.json and verify that its sha256 is 0xeaa42ea06b95d7917d22135a630e65352cfd0a721ae88155a1512468a95cb750 . |
Helper โ
SmartPy provides a helper to encode the URI Python string into bytes: sp.utils.bytes_of_string(<string>)
.
Example:
python
uri = sp.utils.bytes_of_string(
"ipfs://QmRbmXcd2yfNVdgHL7oYWS2yd3tztr2NZiqP2LFuw3voPW"
)
This helper cannot be translated into Michelson, if cannot be used inside an entrypoint.