Skip to content

Latest commit

History

History
48 lines (34 loc) 路 1.45 KB

publish-flow-onchain.md

File metadata and controls

48 lines (34 loc) 路 1.45 KB

Quickstart: Publish & Consume Flow using onchain data source

This quickstart describes a flow to publish & consume onchain data source

Here are the steps:

  1. Setup
  2. Publish dataset
  3. Consume dataset

Let's go through each step.

1. Setup

Ensure that you've already (a) installed Ocean, and (b) set up locally or remotely.

2. Publish dataset

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.

3. Consume the dataset

(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.)