Skip to content

Latest commit

 

History

History
81 lines (57 loc) · 2.08 KB

datatokens-flow.md

File metadata and controls

81 lines (57 loc) · 2.08 KB

Quickstart: Publish datatoken

Prerequisites

Run barge services

Ocean barge runs ganache (local blockchain), Provider (data service), and Aquarius (metadata cache).

In a new console:

#grab repo
git clone https://github.com/oceanprotocol/barge
cd barge

#clean up old containers (to be sure)
docker system prune -a --volumes

#run barge: start ganache, Provider, Aquarius; deploy contracts; update ~/.ocean
./start_ocean.sh  --with-provider2

Install the library, set envvars

In a new console:

#Initialize virtual environment and activate it.
python -m venv venv
source venv/bin/activate

#Install the ocean.py library. Install wheel first to avoid errors.
pip install wheel
pip install ocean-lib

#set envvars
export TEST_PRIVATE_KEY1=0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58

#set the address file only for ganache
export ADDRESS_FILE=~/.ocean/ocean-contracts/artifacts/address.json

#set network URL
export OCEAN_NETWORK_URL=http://127.0.0.1:8545

#go into python
python

Publish datatokens

In the Python console:

import os
from ocean_lib.example_config import ExampleConfig
from ocean_lib.ocean.ocean import Ocean
from ocean_lib.web3_internal.wallet import Wallet

private_key = os.getenv('TEST_PRIVATE_KEY1')
config = ExampleConfig.get_config()
ocean = Ocean(config)

print("create wallet: begin")
wallet = Wallet(ocean.web3, private_key, config.block_confirmations, config.transaction_timeout)
print(f"create wallet: done. Its address is {wallet.address}")

print("create datatoken: begin.")
datatoken = ocean.create_data_token("Dataset name", "dtsymbol", from_wallet=wallet)
print(f"created datatoken: done. Its address is {datatoken.address}")

Congrats, you've created your first Ocean datatoken! 🐋