This quickstart describes a flow to publish & consume onchain data source
Here are the steps:
- Setup
- Publish dataset
- Consume dataset
Let's go through each step.
Ensure that you've already (a) installed Ocean, and (b) set up locally or remotely.
In the same Python console:
#data info
from ocean_lib.ocean.util import get_address_of_type
name = "swapOceanFee function call"
contract_address = get_address_of_type(config, "Router")
contract_abi = {
"inputs": [],
"name": "swapOceanFee",
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
"stateMutability": "view",
"type": "function",
}
#create asset
(data_nft, datatoken, ddo) = ocean.assets.create_onchain_asset(name, contract_address, contract_abi, {"from": alice})
print(f"Just published asset, with did={ddo.did}")
That's it! You've created a data asset of "SmartContractCall" asset type. It includes a data NFT, a datatoken for the data NFT, and metadata.
(Consume here is just like in [consume-flow](READMEs/consume-flow.md]. The file downloaded is a .json. From that, use the python json
library to parse it as desired.)