diff --git a/SUMMARY.md b/SUMMARY.md index 5f10ee64..bdb1b7f8 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -61,9 +61,10 @@ * [Ocean.py](developers/ocean.py/README.md) * [Install](developers/ocean.py/install.md) * [Local Setup](developers/ocean.py/local-setup.md) - * [Remote setup](developers/ocean.py/remote-setup.md) + * [Remote Setup](developers/ocean.py/remote-setup.md) * [Publish flow](developers/ocean.py/publish-flow.md) * [Consume flow](developers/ocean.py/consume-flow.md) + * [Technical Details](developers/ocean.py/technical-details.md) * [Ocean.js](developers/ocean.js/README.md) * [Configuration](developers/ocean.js/configuration.md) * [Creating a data NFT](developers/ocean.js/creating-datanft.md) diff --git a/developers/ocean.py/consume-flow.md b/developers/ocean.py/consume-flow.md index 3fde0f64..06d1d6e2 100644 --- a/developers/ocean.py/consume-flow.md +++ b/developers/ocean.py/consume-flow.md @@ -51,10 +51,12 @@ ocean.OCEAN_token.approve(exchange.address, OCEAN_needed, {"from":bob}) exchange.buy_DT(to_wei(1), consume_market_fee=0, tx_dict={"from": bob}) ``` -For more info, see [Appendix: Dispenser / Faucet Details](https://github.com/oceanprotocol/ocean.py/blob/main/READMEs/main-flow.md#appendix-faucet-details) and [Exchange Details](https://github.com/oceanprotocol/ocean.py/blob/main/READMEs/main-flow.md#appendix-exchange-details). +For more info, check [Technical Details](https://app.gitbook.com/o/mTcjMqA4ylf55anucjH8/s/BTXXhmDGzR0Xgj13fyfM/\~/changes/336/developers/ocean.py/technical-details) about ocean.py most used functions and also the smart contracts for [Dispenser](https://github.com/oceanprotocol/contracts/blob/main/contracts/pools/dispenser/Dispenser.sol) & [Fixed Rate Exchange](https://github.com/oceanprotocol/contracts/blob/main/contracts/pools/fixedRate/FixedRateExchange.sol). ### Consume the asset ⬇️ +To "consume" an asset typically means placing an "order", where you pass in 1.0 datatokens and get back a url. Then, you typically download the asset from the url. + Bob now has the datatoken for the dataset! Time to download the dataset and use it.
@@ -97,5 +99,3 @@ The _beginning_ of the file should contain the following contents: -3.9286,0.0000,206.1783 ... ``` - -For more info, see [Appendix: Consume Details](https://github.com/oceanprotocol/ocean.py/blob/main/READMEs/main-flow.md#appendix-consume-details). diff --git a/developers/ocean.py/publish-flow.md b/developers/ocean.py/publish-flow.md index b6cfdfee..36c1b10c 100644 --- a/developers/ocean.py/publish-flow.md +++ b/developers/ocean.py/publish-flow.md @@ -37,4 +37,95 @@ You've now published an Ocean asset!
-For more info, see [Appendix: Publish Details](https://github.com/oceanprotocol/ocean.py/blob/main/READMEs/main-flow.md#appendix-publish-details). +### Appendix + +For more information regarding: Data NFT & Datatokens interfaces and how they are implemented in Solidity, we suggest to follow up this [article](../datanft-and-datatoken/) and [contracts repo](https://github.com/oceanprotocol/contracts) from GitHub. + +As you may want to explore more the DDO specs, structure & meaning, we invite you to consult [DDO Specification](../ddo-specification.md) section. + +#### Publishing Alternatives + +Here's an example similar to the `create()` step above, but exposes more fine-grained control. + +In the same python console: + +```python +# Specify metadata and services, using the Branin test dataset +date_created = "2021-12-28T10:55:11Z" +metadata = { + "created": date_created, + "updated": date_created, + "description": "Branin dataset", + "name": "Branin dataset", + "type": "dataset", + "author": "Trent", + "license": "CC0: PublicDomain", +} + +# Use "UrlFile" asset type. (There are other options) +from ocean_lib.structures.file_objects import UrlFile +url_file = UrlFile( + url="https://raw.githubusercontent.com/trentmc/branin/main/branin.arff" +) + +# Publish data asset +from ocean_lib.models.datatoken_base import DatatokenArguments +_, _, ddo = ocean.assets.create( + metadata, + {"from": alice}, + datatoken_args=[DatatokenArguments(files=[url_file])], +) +``` + +#### DDO Encryption or Compression + +The DDO is stored on-chain. It's encrypted and compressed by default. Therefore it supports GDPR "right-to-be-forgotten" compliance rules by default. + +You can control this during `create()`: + +* To disable encryption, use `ocean.assets.create(..., encrypt_flag=False)`. +* To disable compression, use `ocean.assets.create(..., compress_flag=False)`. +* To disable both, use `ocean.assetspy.create(..., encrypt_flag=False, compress_flag=False)`. + +#### Create _just_ a data NFT + +Calling `create()` like above generates a data NFT, a datatoken for that NFT, and a ddo. This is the most common case. However, sometimes you may want _just_ the data NFT, e.g. if using a data NFT as a simple key-value store. Here's how: + +```python +data_nft = ocean.data_nft_factory.create({"from": alice}, 'NFT1', 'NFT1') +``` + +If you call `create()` after this, you can pass in an argument `data_nft_address:string` and it will use that NFT rather than creating a new one. + +#### Create a datatoken from a data NFT + +Calling `create()` like above generates a data NFT, a datatoken for that NFT, and a ddo object. However, we may want a second datatoken. Or, we may have started with _just_ the data NFT, and want to add a datatoken to it. Here's how: + +```python +datatoken = data_nft.create_datatoken({"from": alice}, "Datatoken 1", "DT1") +``` + +If you call `create()` after this, you can pass in an argument `deployed_datatokens:List[Datatoken1]` and it will use those datatokens during creation. + +#### Create an asset & pricing schema simultaneously + +Ocean Assets allows you to bundle several common scenarios as a single transaction, thus lowering gas fees. + +Any of the `ocean.assets.create__asset()` functions can also take an optional parameter that describes a bundled pricing schema (Dispenser or Fixed Rate Exchange). + +Here is an example involving an exchange: + +{% code overflow="wrap" %} +```python +from ocean_lib.models.fixed_rate_exchange import ExchangeArguments +(data_nft, datatoken, ddo) = ocean.assets.create_url_asset( + name, + url, + {"from": alice}, + pricing_schema_args=ExchangeArguments(rate=to_wei(3), base_token_addr=ocean.OCEAN_address, dt_decimals=18) +) + +assert len(datatoken.get_exchanges()) == 1 +``` +{% endcode %} + diff --git a/developers/ocean.py/remote-setup.md b/developers/ocean.py/remote-setup.md index c884e8d9..a35685be 100644 --- a/developers/ocean.py/remote-setup.md +++ b/developers/ocean.py/remote-setup.md @@ -2,7 +2,7 @@ description: Remote setup for running & testing ocean.py --- -# Remote setup +# Remote Setup Here, we do setup for Mumbai, the testnet for Polygon. It's similar for other remote chains. diff --git a/developers/ocean.py/technical-details.md b/developers/ocean.py/technical-details.md new file mode 100644 index 00000000..5cc2ceb3 --- /dev/null +++ b/developers/ocean.py/technical-details.md @@ -0,0 +1,2 @@ +# Technical Details +