Data NFTs can store arbitrary key-value pairs, to be an on-chain key-value store.
They can be used for:
- Publicly sharing AI models of small to medium size
- Publicly sharing AI model predictions
- Comments & ratings in Dapps
- Digital Attestations, e.g. for verifiable credentials
This flow is appropriate for:
- Public data. The next README will explore for private sharing.
- Small to medium-sized datasets. For larger datasets, store the data off-chain and share via Ocean datatokens.
Here are the steps:
- Setup
- Publish data NFT
- Add key-value pair to data NFT
- Retrieve value from data NFT
Ensure that you've already (a) installed Ocean, and (b) set up locally or remotely.
In Python console:
data_nft = ocean.data_nft_factory.create({"from": alice}, 'NFT1', 'NFT1')
# Key-value pair
model_key = "my_MLP"
model_value = "<insert MLP weights here>"
# set
data_nft.set_data(model_key, model_value, {"from": alice})
model_value2 = data_nft.get_data(model_key)
print(f"Found that {model_key} = {model_value2}")
This data is public, so anyone can retrieve it.
That's it! Note the simplicity. All data was stored and retrieved from on-chain. We don't need Ocean Provider or Ocean Aquarius for these use cases (though the latter can help for fast querying & retrieval).
Under the hood, it uses ERC725, which augments ERC721 with a well-defined way to set and get key-value pairs.
This README showed how to share public key-value data. The next README covers private data. Let's go there!.