1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

Merge branch 'main' into feature/c2d_detailed_flow

This commit is contained in:
Ana Loznianu 2023-11-01 14:02:45 +02:00
commit f171a00024
21 changed files with 165 additions and 153 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -17,9 +17,21 @@ When you publish an asset on the Ocean marketplace, there are currently no charg
However, if you're building a custom marketplace, you have the flexibility to include a publishing fee by adding an extra transaction in the publish flow. Depending on your marketplace's unique use case, you, as the marketplace owner, can decide whether or not to implement this fee. We believe in giving you the freedom to tailor your marketplace to your specific needs and preferences.
| Value in Ocean Market | Value in Other Markets |
| --------------------- | ------------------------------ |
| 0% | Customizable in market config. |
| Value in Ocean Market | Value in Other Markets |
| :---------------------: | :------------------------------: |
| 0% | Customizable in market config. |
### Swap fee
Swap fees are incurred as a transaction cost whenever someone exchanges one type of token for another within a [fixed rate exchange](./pricing-schemas.md#fixed-pricing). These exchanges can involve swapping a datatoken for a basetoken, like OCEAN or H2O, or vice versa, where basetoken is exchanged for datatoken. The specific value of the swap fee depends on the type of token being used in the exchange.
The swap fee values are set at the smart contract level and can only be modified by the Ocean Protocol Foundation (OPF).
| Value for OCCEAN or H2O | Value for other ERC20 tokens |
| :-----------------------: | :-----------------------------: |
| 0.1% | 0.2% |
### Consume(aka. Order) fee
@ -32,7 +44,7 @@ When a user exchanges a [datatoken](datatokens.md) for the privilege of download
* Eg: A market can set a fixed fee of 10 USDT per order, no matter what pricing schemas are used (fixedrate with ETH, BTC, dispenser, etc).
2. **Consume Market** Consumption Fee
* A market can specify what fee it wants on the order function.
3. **Provider Consumption** Fees
3. **Provider** Consumption Fees
* Defined by the [Provider](../provider/README.md) for any consumption.
* Expressed in: Address, Token, Amount (absolute), Timeout.
* You can retrieve them when calling the initialize endpoint.

View File

@ -29,3 +29,77 @@ The module structure follows this format:
* Utils
When working with a particular module, you will need to provide different parameters. To instantiate classes from the contracts module, you must pass objects such as Signer, which represents the wallet instance, or the contract address you wish to utilize, depending on the scenario. As for the services modules, you will need to provide the provider URI or metadata cache URI.
# Examples and Showcases 🌟🚀
Ocean.js is more than just a library; it's a gateway to unlocking your potential in the world of decentralized data services. To help you understand its real-world applications, we've curated a collection of examples and showcases. These examples demonstrate how you can use Ocean.js to create innovative solutions that harness the power of decentralized technologies. Each example provides a unique perspective on how you can apply Ocean.js, from decentralized marketplaces for workshops to peer-to-peer platforms for e-books and AI-generated art. These showcases serve as an inspiration for developers like you, looking to leverage Ocean.js in your projects, showcasing its adaptability and transformative capabilities. Dive into these examples to see how Ocean.js can bring your creative visions to life. 📚
<table data-view="cards">
<thead>
<tr>
<th></th>
<th></th>
<th data-hidden data-card-cover data-type="files"></th>
<th data-hidden data-card-target data-type="content-ref"></th>
</tr>
</thead>
<tbody>
<tr>
<td>Decentralised Data Marketplace 🌊</td>
<td>A decentralised marketplace for peer-to-peer online workshops.</td>
<td><a href="../../.gitbook/assets/templates/marketplace.png">marketplace.png</a></td>
<td><a href="https://github.com/oceanprotocol/market">https://github.com/oceanprotocol/market</a></td>
</tr>
<tr>
<td>Music NFTs Marketplace 🎼</td>
<td>A peer-to-peer platform for buying on-demand music NFTs.</td>
<td><a href="../../.gitbook/assets/templates/ocean_waves.png">ocean_waves.png</a></td>
<td><a href="https://github.com/oceanprotocol/waves">https://github.com/oceanprotocol/waves</a></td>
</tr>
<tr>
<td>Tokengated Content 🔒</td>
<td>A decentralised marketplace for buying &#x26; selling AI-generated Art.</td>
<td><a href="../../.gitbook/assets/templates/tokengate.png">tokengate.png</a></td>
<td><a href="https://github.com/oceanprotocol/token-gating-template">https://github.com/oceanprotocol/token-gating-template</a></td>
</tr>
<tr>
<td>Tokengated AI Chatbot 🤖</td>
<td>A decentralised e-commerce platform to sell templates, UI kits and plugins.</td>
<td><a href="../../.gitbook/assets/templates/tokengated_chatbot.png">tokengated_chatbot.png</a></td>
<td><a href="https://github.com/oceanprotocol/tokengated-next-chatgpt">https://github.com/oceanprotocol/tokengated-next-chatgpt</a></td>
</tr>
<tr>
<td>Buy &#x26; Sell Online Workshops 🎓</td>
<td>A decentralised marketplace for peer-to-peer online workshops.</td>
<td><a href="../../.gitbook/assets/templates/oceanLearn.jpg">oceanLearn.jpg</a></td>
<td><a href="https://www.figma.com/proto/8nT6qEUMMmJsMs8Ow2KzAN/OceanLearn?type=design&#x26;scaling=min-zoom&#x26;page-id=5%3A44&#x26;starting-point-node-id=5%3A91">https://www.figma.com/proto/8nT6qEUMMmJsMs8Ow2KzAN/OceanLearn?type=design&#x26;scaling=min-zoom&#x26;page-id=5%3A44&#x26;starting-point-node-id=5%3A91</a></td>
</tr>
<tr>
<td>E-Books On-Demand 📖</td>
<td>A peer-to-peer platform for reading on-demand e-books.</td>
<td><a href="../../.gitbook/assets/templates/oceanReads.jpg">oceanReads.jpg</a></td>
<td><a href="https://www.figma.com/proto/xReYRMMnhrynRsNqdy63tT/OceanReads?type=design&#x26;node-id=28-380&#x26;scaling=min-zoom&#x26;page-id=28%3A380&#x26;starting-point-node-id=135%3A92">https://www.figma.com/proto/xReYRMMnhrynRsNqdy63tT/OceanReads?type=design&#x26;node-id=28-380&#x26;scaling=min-zoom&#x26;page-id=28%3A380&#x26;starting-point-node-id=135%3A92</a></td>
</tr>
<tr>
<td>Buy Templates, UI Kits, and plugins 🎨</td>
<td>A decentralized e-commerce platform to sell templates, UI kits, and plugins.</td>
<td><a href="../../.gitbook/assets/templates/webPallete.png">webPallete.png</a></td>
<td><a href="https://www.figma.com/proto/xAcyc0rqZNTA8TdW43NN5P/WebPalette?type=design&#x26;node-id=0-1&#x26;scaling=min-zoom&#x26;page-id=0%3A1&#x26;starting-point-node-id=9%3A138">https://www.figma.com/proto/xAcyc0rqZNTA8TdW43NN5P/WebPalette?type=design&#x26;node-id=0-1&#x26;scaling=min-zoom&#x26;page-id=0%3A1&#x26;starting-point-node-id=9%3A138</a></td>
</tr>
<tr>
<td>Decentralised Ticketing Mobile App 📱</td>
<td>The first end-to-end decentralized mobile App to buy, sell &#x26; trade tickets of any type.</td>
<td><a href="../../.gitbook/assets/templates/TicketingMobileApp.png">TicketingMobileApp.png</a></td>
<td><a href="https://www.figma.com/proto/lu5ODNDwIrJmlM0WqBeBJ3/OceanTickets?page-id=75%3A386&#x26;type=design&#x26;node-id=336-126&#x26;viewport=131%2C706%2C0.19&#x26;t=ia9UyDUfZxZQS4k1-1&#x26;scaling=scale-down&#x26;starting-point-node-id=336%3A126">https://www.figma.com/proto/lu5ODNDwIrJmlM0WqBeBJ3/OceanTickets?page-id=75%3A386&#x26;type=design&#x26;node-id=336-126&#x26;viewport=131%2C706%2C0.19&#x26;t=ia9UyDUfZxZQS4k1-1&#x26;scaling=scale-down&#x26;starting-point-node-id=336%3A126</a></td>
</tr>
<tr>
<td>Publish &#x26; Collect Digital Art 🖼️</td>
<td>A decentralised marketplace for buying &#x26; selling AI-generated Art.</td>
<td><a href="../../.gitbook/assets/templates/oceanArt.jpg">oceanArt.jpg</a></td>
<td><a href="https://www.figma.com/proto/LwbMqloVagXnmlaeDCFiJC/OceanArt?type=design&#x26;node-id=13-122&#x26;scaling=min-zoom&#x26;page-id=13%3A122&#x26;starting-point-node-id=13%3A169">https://www.figma.com/proto/LwbMqloVagXnmlaeDCFiJC/OceanArt?type=design&#x26;node-id=13-122&#x26;scaling=min-zoom&#x26;page-id=13%3A122&#x26;starting-point-node-id=13%3A169</a></td>
</tr>
</tbody>
</table>
With these examples and showcases, you've seen just a glimpse of what you can achieve with this library. Now, it's your turn to dive in, explore, and unleash your creativity using Ocean.js. 🚀

View File

@ -14,7 +14,7 @@ ocean.py lets you do the following things:
* Publish data services: downloadable files or compute-to-data. Create an ERC721 data NFT for each service, and ERC20 datatoken for access (1.0 datatokens to access).
* Sell datatokens via for a fixed price. Sell data NFTs.
* Transfer data NFTs & datatokens to another owner, and all other ERC721 & ERC20 actions using Brownie.
* Transfer data NFTs & datatokens to another owner, and all other ERC721 & ERC20 actions using web3.
If you prefer video format, please check this video below, otherwise let's move forward.

View File

@ -16,7 +16,7 @@ It is implemented in DatatokenBase, inherited by Datatoken2, so it can be called
**Parameters**
* `tx_dict` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc. For more info, check [Brownie docs](https://eth-brownie.readthedocs.io/en/stable/).
* `tx_dict` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
* `max_tokens` - maximum amount of tokens to dispense in wei. The default is a large number.
* `max_balance` - maximum balance of requester in wei. The default is a large number.
* `with_mint` - boolean, `true` if we want to allow the dispenser to be a minter as default value
@ -93,7 +93,7 @@ It is implemented in DatatokenBase, so it can be called within Datatoken class.
**Parameters**
* `amount` - amount of datatokens to be dispensed in wei (int or string format)
* `tx_dict` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc. For more info, check [Brownie docs](https://eth-brownie.readthedocs.io/en/stable/).
* `tx_dict` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
**Returns**
@ -148,7 +148,7 @@ It is implemented in `Datatoken2`, so it can be called within `Datatoken2` class
* `consumer` - address of the consumer wallet that needs funding
* `service_index` - service index as int for identifying the service that you want to further call [`start_order`](https://github.com/oceanprotocol/ocean.py/blob/4aa12afd8a933d64bc2ed68d1e5359d0b9ae62f9/ocean_lib/models/datatoken.py#LL169C5-L197C10).
* `transaction_parameters` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc. For more info, check [Brownie docs](https://eth-brownie.readthedocs.io/en/stable/).
* `transaction_parameters` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
* `consume_market_fees` - [`TokenInfo` ](https://github.com/oceanprotocol/ocean.py/blob/4aa12afd8a933d64bc2ed68d1e5359d0b9ae62f9/ocean_lib/models/datatoken.py#L31)object which contains the consume market fee amount, address & token address. If it is not explicitly specified, by default it has an empty `TokenInfo` object.
**Returns**
@ -275,7 +275,7 @@ This wraps the smart contract method `Datatoken.createFixedRate()` with a simple
* `rate` - how many base tokens does 1 datatoken cost? In wei or string
* `base_token_addr` - e.g. OCEAN address
* `tx_dict` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc. For more info, check [Brownie docs](https://eth-brownie.readthedocs.io/en/stable/).
* `tx_dict` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
**Optional parameters**
@ -314,7 +314,7 @@ This wraps the smart contract method `Datatoken.createFixedRate()` with a simple
allowed_swapper: str = ZERO_ADDRESS,
full_info: bool = False,
) -> Union[OneExchange, tuple]:
# import now, to avoid circular import
from ocean_lib.models.fixed_rate_exchange import OneExchange
@ -369,7 +369,7 @@ It is implemented in `Datatoken` class and it is also inherited in `Datatoken2`
* `consumer` - address of the consumer wallet that needs funding
* `service_index` - service index as int for identifying the service that you want to further call [`start_order`](https://github.com/oceanprotocol/ocean.py/blob/4aa12afd8a933d64bc2ed68d1e5359d0b9ae62f9/ocean_lib/models/datatoken.py#LL169C5-L197C10).
* `transaction_parameters` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc. For more info, check [Brownie docs](https://eth-brownie.readthedocs.io/en/stable/).
* `transaction_parameters` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
* `consume_market_fees` - [`TokenInfo` ](https://github.com/oceanprotocol/ocean.py/blob/4aa12afd8a933d64bc2ed68d1e5359d0b9ae62f9/ocean_lib/models/datatoken.py#L31)object which contains the consume market fee amount, address & token address. If it is not explicitly specified, by default it has an empty `TokenInfo` object.
**Returns**
@ -422,8 +422,8 @@ Return value is a hex string for transaction hash which denotes the proof of sta
consume_market_fees=consume_market_fees,
transaction_parameters=transaction_parameters,
)
```
</details>
@ -480,7 +480,7 @@ It is implemented in Datatoken class and it is also inherited in Datatoken2 clas
* `consumer` - address of the consumer wallet that needs funding
* `service_index` - service index as int for identifying the service that you want to apply `start_order`.
* `provider_fees` - dictionary which includes provider fees generated when `initialize` endpoint from `Provider` was called.
* `transaction_parameters` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc. For more info, check [Brownie docs](https://eth-brownie.readthedocs.io/en/stable/).
* `transaction_parameters` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
* `consume_market_fees` - [`TokenInfo` ](https://github.com/oceanprotocol/ocean.py/blob/4aa12afd8a933d64bc2ed68d1e5359d0b9ae62f9/ocean_lib/models/datatoken.py#L31)object which contains the consume market fee amount, address & token address. If it is not explicitly specified, by default it has an empty `TokenInfo` object.
**Returns**
@ -543,7 +543,7 @@ It is implemented in Datatoken class and it is also inherited in Datatoken2 clas
* `order_tx_id` - transaction hash of a previous order, string or bytes format.
* `provider_fees` - dictionary which includes provider fees generated when `initialize` endpoint from `Provider` was called.
* `transaction_parameters` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc. For more info, check [Brownie docs](https://eth-brownie.readthedocs.io/en/stable/).
* `transaction_parameters` - is the configuration `dictionary` for that specific transaction. Usually for `development` we include just the `from` wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
**Returns**

View File

@ -41,11 +41,7 @@ Issue: MacOS “Unsupported Architecture”
* If you run MacOS, you may encounter an “Unsupported Architecture” issue.
* Workaround: install including ARCHFLAGS: `ARCHFLAGS="-arch x86_64" pip install ocean-lib`. [Details](https://github.com/oceanprotocol/ocean.py/issues/486).
To install ocean-lib using Python 3.11, run `pip install vyper==0.3.7 --ignore-requires-python` and `sudo apt-get install python3.11-dev` before installing ocean-lib. Since the parsimonious dependency does not support Python 3.11, you need to edit the `parsimonious/expressions.py` to `import getfullargspec as getargsspec` instead of the regular import. These are temporary fixes until all dependencies are fully supported in Python 3.11. We do not directly use Vyper in ocean-lib.
### ocean.py uses Brownie
Let's dive deeper into the Ocean world! 💙 Did you know that Ocean and Brownie are like best buddies? When you installed Ocean (ocean-lib pypi package) earlier, it automatically took care of installing Brownie (eth-brownie package) too. Talk about a dynamic duo! 🦸‍♀️🦸‍♂️
### why we 🥰 ocean.py
`ocean.py` treats each Ocean smart contract as a Python class, and each deployed smart contract as a Python object. We love this feature, because it means Python programmers can treat Solidity code as Python code! 🤯

View File

@ -38,20 +38,13 @@ cd barge
docker system prune -a --volumes
# Run barge: start Ganache, Provider, Aquarius; deploy contracts; update ~/.ocean
export GANACHE_HARDFORK=london # for support of type 2 transactions
./start_ocean.sh
```
Let barge do its magic and wait until the blockchain is fully synced. That means when you start to see continuosly `eth_blockNumber`
Let barge do its magic and wait until the blockchain is fully synced. That means when you start to see continuously `eth_blockNumber`
### 2. Brownie local network configuration
(You don't need to do anything in this step, it's just useful to understand.)
Brownie's network configuration file is at `~/.brownie/network-config.yaml`.
When running locally, Brownie will use the chain listed under `development`, having id `development`. This refers to Ganache, which is running in Barge.
### 3. Set envvars
### 2. Set envvars
From here on, go to a console different than Barge. (E.g. the console where you installed Ocean, or a new one.)
@ -74,7 +67,7 @@ export TEST_PRIVATE_KEY2=0x1d751ded5a32226054cd2e71261039b65afb9ee1c746d055dd699
export FACTORY_DEPLOYER_PRIVATE_KEY=0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58
```
### 4. Setup in Python
### 3. Setup in Python
In the same console, run Python console:
@ -86,11 +79,8 @@ In the Python console:
```python
# Create Ocean instance
from ocean_lib.web3_internal.utils import connect_to_network
connect_to_network("development")
from ocean_lib.example_config import get_config_dict
config = get_config_dict("development")
config = get_config_dict("http://localhost:8545")
from ocean_lib.ocean.ocean import Ocean
ocean = Ocean(config)
@ -104,17 +94,16 @@ mint_fake_OCEAN(config)
# Create Alice's wallet
import os
from brownie.network import accounts
accounts.clear()
from eth_account import Account
alice_private_key = os.getenv("TEST_PRIVATE_KEY1")
alice = accounts.add(alice_private_key)
alice = Account.from_key(private_key=alice_private_key)
assert alice.balance() > 0, "Alice needs ETH"
assert OCEAN.balanceOf(alice) > 0, "Alice needs OCEAN"
# Create additional wallets. While some flows just use Alice wallet, it's simpler to do all here.
bob_private_key = os.getenv('TEST_PRIVATE_KEY2')
bob = accounts.add(bob_private_key)
bob = Account.from_key(private_key=bob_private_key)
assert bob.balance() > 0, "Bob needs ETH"
assert OCEAN.balanceOf(bob) > 0, "Bob needs OCEAN"

View File

@ -20,7 +20,7 @@ It can be called after instantiating Ocean object.
* `name` - name of the asset, `string`
* `url` - url that is stored in the asset, `string`
* `publisher_wallet` - wallet of the asset publisher/owner, `Brownie account`
* `publisher_wallet` - wallet of the asset publisher/owner, `eth Account`
* `wait_for_aqua` - boolean value which default is `True`, waiting for aquarius to fetch the asset takes additional time, but if you want to be sure that your asset is indexed, keep the default value.
**Returns**
@ -64,7 +64,7 @@ It can be called after instantiating Ocean object.
* `name` - name of the asset, `string`
* `url` - url that is stored in the asset, `string`
* `publisher_wallet` - wallet of the asset publisher/owner, `Brownie account`
* `publisher_wallet` - wallet of the asset publisher/owner, `eth Account`
* `image` - docker image of that algorithm, `string`
* `tag` - docker tag for that algorithm image, `string`
* `checksum` - docker checksum for algorithm's image, `string`
@ -134,7 +134,7 @@ It can be called after instantiating Ocean object.
* `name` - name of the asset, `string`
* `transaction_id` - transaction id from the arweave file, `string`
* `publisher_wallet` - wallet of the asset publisher/owner, `Brownie account`
* `publisher_wallet` - wallet of the asset publisher/owner, `eth Account`
* `wait_for_aqua` - boolean value which default is `True`, waiting for aquarius to fetch the asset takes additional time, but if you want to be sure that your asset is indexed, keep the default value.
**Returns**
@ -183,7 +183,7 @@ It can be called after instantiating Ocean object.
* `name` - name of the asset, `string`
* `url` - url of subgraph that you are using, `string`
* `query` - GraphQL query, `string`
* `publisher_wallet` - wallet of the asset publisher/owner, `Brownie account`
* `publisher_wallet` - wallet of the asset publisher/owner, `eth Account`
* `wait_for_aqua` - boolean value which default is `True`, waiting for aquarius to fetch the asset takes additional time, but if you want to be sure that your asset is indexed, keep the default value.
**Returns**
@ -233,7 +233,7 @@ It can be called after instantiating Ocean object.
* `name` - name of the asset, `string`
* `contract_address` - contract address that should be stored in the asset, `string`
* `contract_abi` - ABI of functions presented in the contract, `string`
* `publisher_wallet` - wallet of the asset publisher/owner, `Brownie account`
* `publisher_wallet` - wallet of the asset publisher/owner, `eth Account`
* `wait_for_aqua` - boolean value which default is `True`, waiting for aquarius to fetch the asset takes additional time, but if you want to be sure that your asset is indexed, keep the default value.
**Returns**
@ -283,7 +283,7 @@ Creating/deploying a DataNFT contract and in the Metadata store (Aquarius).
**Parameters**
* `metadata`: `dictionary` conforming to the Metadata accepted by Ocean Protocol.
* `publisher_wallet`- `Brownie account` of the publisher registering this asset.
* `publisher_wallet`- `eth Account` of the publisher registering this asset.
* `credentials` - credentials `dictionary` necessary for the asset, which establish who can consume the asset and who cannot.
* `data_nft_address`- hex string, the address of the data NFT. The new asset will be associated with this data NFT address.
* `data_nft_args`- object of DataNFTArguments type if creating a new one.
@ -324,7 +324,7 @@ def create(
compress_flag: Optional[bool] = True,
wait_for_aqua: bool = True,
) -> Optional[DDO]:
self._assert_ddo_metadata(metadata)
provider_uri = DataServiceProvider.get_url(self._config_dict)
@ -556,7 +556,7 @@ The updated DDO, or `None` if updated DDO not found in Aquarius.
encrypt_flag: Optional[bool] = True,
compress_flag: Optional[bool] = True,
) -> Optional[DDO]:
self._assert_ddo_metadata(ddo.metadata)
if not provider_uri:
@ -738,7 +738,7 @@ Downloads the asset from Ocean Market.
**Parameters**
* `ddo` - DDO to be downloaded.
* `consumer_wallet` - Brownie account for the wallet that "ordered" the asset.
* `consumer_wallet` - eth Account for the wallet that "ordered" the asset.
* `destination` - destination path, as string, where the asset will be downloaded.
* `order_tx_id` - transaction ID for the placed order, string and bytes formats are accepted.
@ -803,7 +803,7 @@ Pays for access service by calling initialize endpoint from Provider and startin
**Parameters**
* `ddo` - DDO to be downloaded.
* `wallet`- Brownie account for the wallet that pays for the asset.
* `wallet`- eth Account for the wallet that pays for the asset.
**Optional parameters**
@ -900,7 +900,7 @@ Pays for compute service by calling `initializeCompute` endpoint from Provider t
* `compute_environment` - `string` that represents the ID from the chosen C2D environment.
* `valid_until` - `UNIX timestamp` which represents until when the algorithm can be used/run.
* `consume_market_order_fee_address` - string address which denotes the consume market fee address for that order and can be the wallet address itself.
* `wallet` - the `Brownie account` which pays for the compute service
* `wallet` - the `eth Account` which pays for the compute service
**Optional parameters**

View File

@ -16,7 +16,7 @@ It can be called within Ocean Compute class.
**Parameters**
* `consumer_wallet` - the `Brownie account` of consumer who pays & starts for compute job.
* `consumer_wallet` - the `eth Account` of consumer who pays & starts for compute job.
* `dataset` - `ComputeInput` object, each of them includes mandatory the DDO and service.
* `compute_environment` - `string` that represents the ID from the chosen C2D environment.
* `additional_datasets` - list of `ComputeInput` objects for additional datasets in case of starting a compute job for multiple datasets.
@ -98,7 +98,7 @@ It can be called within Ocean Compute class.
* `ddo` - DDO offering the compute service of this job
* `service` - Service object of compute
* `job_id` - ID of the compute job
* `wallet` - Brownie account which initiated the compute job
* `wallet` - eth Account which initiated the compute job
**Returns**
@ -152,7 +152,7 @@ It can be called within Ocean Compute class.
* `service` - Service object of compute
* `job_id` - ID of the compute job
* `index` - compute result index
* `wallet` - Brownie account which initiated the compute job
* `wallet` - eth Account which initiated the compute job
**Returns**
@ -205,7 +205,7 @@ It can be called within Ocean Compute class.
* `ddo` - DDO offering the compute service of this job
* `service` - Service object of compute
* `job_id` - ID of the compute job
* `wallet` - Brownie account which initiated the compute job
* `wallet` - eth Account which initiated the compute job
* `log_type` - string which selects what kind of logs to display. Default "output"
**Returns**
@ -265,7 +265,7 @@ It can be called within Ocean Compute class.
* `ddo` - DDO offering the compute service of this job
* `service` - Service object of compute
* `job_id` - ID of the compute job
* `wallet` - Brownie account which initiated the compute job
* `wallet` - eth Account which initiated the compute job
**Returns**

View File

@ -10,7 +10,7 @@ Here, we do setup for Mumbai, the testnet for Polygon. It's similar for other re
Here, we will:
1. Configure Brownie networks
1. Configure Networks
2. Create two accounts - `REMOTE_TEST_PRIVATE_KEY1` and `2`
3. Get test MATIC on Mumbai
4. Get test OCEAN on Mumbai
@ -19,101 +19,20 @@ Here, we will:
Let's go!
### 1. Configure Brownie Networks (One-Time)
### 1. Configure Networks
#### 1.1 Network config file
#### 1.1 Supported networks
Brownie's network config file is `network-config.yaml`. It is located in the `.brownie/` subfolder of your home folder.
All [Ocean chain deployments](https://docs.oceanprotocol.com/discover/networks) (Eth mainnet, Polygon, etc) are supported.
For any supported network, use the RPC URL of your choice when passing it to the ocean config object.
* For Linux & MacOS, it's: `~/.brownie/network-config.yaml`
* For Windows users, it's: `C:\Users\<user_name>\.brownie\network-config.yaml`
#### 1.2 Generate network config file (if needed)
If you already see the config file, skip this section.
If you don't, you need to auto-generate by calling any brownie function from a Python console. Here's an example.
First, in a new or existing console, run Python:
```bash
python
```
In the Python console:
```python
from ocean_lib.example_config import get_config_dict
```
It will generate the file in the target location. You can check the target location to confirm.
#### 1.3 Contents of network config file
The network configuration file has settings for each network, e.g. development (ganache), Ethereum mainnet, Polygon, and Mumbai.
Each network gets specifications for:
* `host` - the RPC URL, i.e. what URL do we pass through to talk to the chain
* `required_confs` - the number of confirmations before a tx is done
* `id` - e.g. `polygon-main` (Polygon), `polygon-test` (Mumbai)
`development chains` run locally; `live` chains run remotely.
The example `network-config.yaml` in Brownie's GitHub repo is [here](https://github.com/eth-brownie/brownie/blob/master/brownie/data/network-config.yaml). It can serve as a comparison to your local copy.
Ocean.py follows the exact `id` name for the network's name from the default Brownie configuration file. Therefore, you need to ensure that your target network name matches the corresponding Brownie `id`.
#### 1.4 Networks Supported
All [Ocean-deployed](../../discover/networks/README.md) chains (Eth mainnet, Polygon, etc) should be in Brownie's default `network-config.yaml` except Energy Web Chain (EWC).
For Windows users: it's possible that your `network-config.yaml` doesn't have all the network entries. In this case, just replace your local file's content with the `network-config.yaml` in Brownie's GitHub repo, [here](https://github.com/eth-brownie/brownie/blob/master/brownie/data/network-config.yaml).
For all users: to use EWC, add the following to network-config.yaml:
```yaml
- name: energyweb
networks:
- chainid: 246
host: https://rpc.energyweb.org
id: energyweb
name: energyweb
```
#### 1.5 RPCs and Infura
#### 1.2 RPCs and Infura
In order to obtain API keys for blockchain access, follow up [this document](http://127.0.0.1:5000/o/mTcjMqA4ylf55anucjH8/s/zQlpIJEeu8x5yl0OLuXn/) for tips & tricks.
The config file's default RPCs point to Infura, which require you to have an Infura account with corresponding token `WEB3_INFURA_PROJECT_ID`.
**If you do have an Infura account**
* Linux & MacOS users: in console: `export WEB3_INFURA_PROJECT_ID=<your infura ID>`
* Windows: in console: `set WEB3_INFURA_PROJECT_ID=<your infura ID>`
**If you do **_**not**_** have an Infura account**
One option is to get an Infura account. A simpler option is to _bypass the need_ for an Infura account: just change to RPCs that don't need Infura.
You can bypass manually: just edit your brownie network config file.
Or you can bypass via the command line. The following command replaces Infura RPCs with public ones in `network-config.yaml`:
* Linux users: in the console:
{% code overflow="wrap" %}
```bash
sed -i 's#https://polygon-mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID#https://polygon-rpc.com/#g; s#https://polygon-mumbai.infura.io/v3/$WEB3_INFURA_PROJECT_ID#https://rpc-mumbai.maticvigil.com#g' ~/.brownie/network-config.yaml
```
{% endcode %}
* MacOS users: you can achieve the same thing with `gnu-sed` and the `gsed` command. (Or just manually edit the file.)
* For Windows: you might need something similar to [powershell](https://www.marek.tokyo/2020/01/remove-string-from-file-in-windows-10.html). (Or just manually edit the file.)
**1.6 Network config file wrapup**
Congrats, you've now configured your Brownie network file! You rarely need to worry about it from now on.
Use the full RPC URL including the base and API key, e.g. for mumbai: `https://polygon-mumbai.infura.io/v3/<API-KEY>`
### 2. Create EVM Accounts (One-Time)
@ -204,30 +123,26 @@ In the Python console:
```python
# Create Ocean instance
from ocean_lib.web3_internal.utils import connect_to_network
connect_to_network("polygon-test") # mumbai is "polygon-test"
import os
from ocean_lib.example_config import get_config_dict
from ocean_lib.ocean.ocean import Ocean
config = get_config_dict("polygon-test")
config = get_config_dict("https://polygon.llamarpc.com") # or use another RPC URL, or an Infura one
ocean = Ocean(config)
# Create OCEAN object. ocean_lib knows where OCEAN is on all remote networks
OCEAN = ocean.OCEAN_token
# Create Alice's wallet
from brownie.network import accounts
accounts.clear()
from eth_account import Account
alice_private_key = os.getenv('REMOTE_TEST_PRIVATE_KEY1')
alice = accounts.add(alice_private_key)
alice = Account.from_key(private_key=alice_private_key)
assert alice.balance() > 0, "Alice needs MATIC"
assert OCEAN.balanceOf(alice) > 0, "Alice needs OCEAN"
# Create Bob's wallet. While some flows just use Alice wallet, it's simpler to do all here.
bob_private_key = os.getenv('REMOTE_TEST_PRIVATE_KEY2')
bob = accounts.add(bob_private_key)
bob = Account.from_key(private_key=bob_private_key)
assert bob.balance() > 0, "Bob needs MATIC"
assert OCEAN.balanceOf(bob) > 0, "Bob needs OCEAN"
@ -235,4 +150,4 @@ assert OCEAN.balanceOf(bob) > 0, "Bob needs OCEAN"
from ocean_lib.ocean.util import to_wei, from_wei
```
If you get a gas-related error like `transaction underpriced`, you'll need to change the `priority_fee` or `max_fee`. See details in [brownie docs](https://eth-brownie.readthedocs.io/en/stable/core-gas.html) or you can check the dedicated [README ](https://github.com/oceanprotocol/ocean.py/blob/main/READMEs/gas-strategy-remote.md)which customize your gas strategy.
If you get a gas-related error like `transaction underpriced`, you'll need to change the `maxFeePerGas` or `maxPriorityFeePerGas`.

View File

@ -13,7 +13,7 @@ In each network, whether it's the Ethereum mainnet, a testnet, or the Polygon/Ma
The Ethereum mainnet is a production network, which means that it is a live and operational network that handles real transactions and has actual economic value. To connect to the Ethereum mainnet using a wallet such as MetaMask, you can click on the network name dropdown and select Ethereum mainnet from the list of available networks.
<table data-header-hidden><thead><tr><th width="100">Gas Token</th><th></th></tr></thead><tbody><tr><td>OCEAN</td><td><a href="https://etherscan.io/token/0x967da4048cD07aB37855c090aAF366e4ce1b9F48">0x967da4048cD07aB37855c090aAF366e4ce1b9F48</a></td></tr><tr><td>Explorer</td><td><a href="https://etherscan.io">https://etherscan.io</a></td></tr></tbody></table>
<table data-header-hidden><thead><tr><th width="100">Gas Token</th><th>ETH(Native token)</th></tr></thead><tbody><tr><td>OCEAN</td><td><a href="https://etherscan.io/token/0x967da4048cD07aB37855c090aAF366e4ce1b9F48">0x967da4048cD07aB37855c090aAF366e4ce1b9F48</a></td></tr><tr><td>Explorer</td><td><a href="https://etherscan.io">https://etherscan.io</a></td></tr></tbody></table>
### Polygon Mainnet
@ -25,6 +25,28 @@ Ocean Protocol is also deployed to Polygon Mainnet, which is another production
Check out the Polygon Bridge [guide](bridges.md) to learn how you can deposit, withdraw and send tokens.
### Oasis Sapphire Mainnet
Ocean Protocol is also deployed to Oasis Sapphire Mainnet, which is a production network that Ocean Protocol uses for [Predictoor](https://predictoor.ai). Ocean Protocol does do not currently support ocean.js, ocean.py, or Ocean Market on Oasis Sapphire. The native token of Oasis Sapphire is ROSE. If you cannot find Oasis Sapphire Mainnet as a predefined network in your wallet, you can manually connect to it by entering the following information during the import process: Network Name: `Oasis Sapphire`, RPC URL: `https://sapphire.oasis.io`, Chain ID: `23294`, Token: `ROSE`.
<table data-header-hidden><thead><tr><th width="100">Gas Token</th><th>ROSE(Native token)</th></tr></thead><tbody><tr><td>OCEAN</td><td><a href="https://explorer.oasis.io/mainnet/sapphire/token/0x39d22B78A7651A76Ffbde2aaAB5FD92666Aca520">0x39d22B78A7651A76Ffbde2aaAB5FD92666Aca520</a></td></tr><tr><td>Explorer</td><td><a href="https://explorer.oasis.io/mainnet/sapphire/">https://explorer.oasis.io/mainnet/sapphire/</a></td></tr></tbody></table>
**Bridge**
Check out our Celer Bridge [guide](https://github.com/oceanprotocol/pdr-backend/blob/main/READMEs/get-ocean-on-sapphire.md#2-transfer-ocean-to-sapphire-mainnet-via-celer) to learn how you can bridge your OCEAN tokens from Ethereum Mainnet to Oasis Sapphire Mainnet.
### Oasis Sapphire Testnet
Ocean Protocol is also deployed to Oasis Sapphire Testnet, which is a test network that Ocean Protocol uses for [Predictoor](https://predictoor.ai). Ocean Protocol does do not currently support ocean.js, ocean.py, or Ocean Market on Oasis Sapphire. The native token of Oasis Sapphire is ROSE. If you cannot find Oasis Sapphire Testnet as a predefined network in your wallet, you can manually connect to it by entering the following information during the import process: Network Name: `Oasis Sapphire Testnet`, RPC URL: `https://testnet.sapphire.oasis.dev`, Chain ID: `23295`, Token: `ROSE`.
<table data-header-hidden><thead><tr><th width="100">Gas Token</th><th>ROSE(Native token)</th></tr></thead><tbody><tr><td>OCEAN</td><td><a href="https://explorer.oasis.io/testnet/sapphire/address/0x973e69303259B0c2543a38665122b773D28405fB">0x973e69303259B0c2543a38665122b773D28405fB</a></td></tr><tr><td>Explorer</td><td><a href="https://explorer.oasis.io/testnet/sapphire/">https://explorer.oasis.io/testnet/sapphire/</a></td></tr></tbody></table>
**Get (fake) OCEAN on Sapphire Testnet**
Check out our [guide](https://github.com/oceanprotocol/pdr-backend/blob/main/READMEs/testnet-faucet.md#get-fake-ocean-on-sapphire-testnet) for how to get fake OCEAN tokens on Sapphire Testnet.
Check out our [guide](https://github.com/oceanprotocol/pdr-backend/blob/main/READMEs/testnet-faucet.md#get-fake-rose-on-sapphire-testnet) for how to get fake ROSE tokens on Oasis Sapphire Testnet.
### BNB Smart Chain
Ocean Protocol is also deployed to BNB Smart Chain, which is another production network. The native token of the BNB Smart Chain is BNB, which is the token of the Binance exchange. If BNB Smart Chain is not listed as a predefined network in your wallet, you can manually connect to it by following Binance's [guide](https://academy.binance.com/en/articles/connecting-metamask-to-binance-smart-chain), which provides detailed instructions on how to connect to BNB Smart Chain.

View File

@ -9,6 +9,10 @@ A bridge is a mechanism that connects two or more separate blockchain networks,
We suggest using the following solutions to transfer OCEAN between Ethereum mainnet and Polygon or BSC.
## Celer Bridge
To transfer OCEAN to and from the Oasis Sapphire Mainnet, we recommend using the [Celer Bridge](https://cbridge.celer.network/1/23294/OCEAN). No bridge is needed for transfering OCEAN to the Oasis Sapphire Testnet because Ocean Protocol offers a [faucet](https://faucet.sapphire.oceanprotocol.com/) for OCEAN on Oasis Sapphire Testnet. Note that Ocean Protocol supports Oasis Sapphire networks for [Predictoor](https://predictoor.ai) development, and does not currently support Oasis Sapphire for ocean.js, ocean.py, or Ocean Market.
## BNB Smart Chain Bridge
To transfer OCEAN to and from the BNB Smart Chain, we recommend using the [Binance Bridge](https://www.bnbchain.org/en/bridge). BSC offers various options such as withdrawing crypto from [Binance](https://www.binance.com/en) and utilizing the [Binance Bridge](https://www.bnbchain.org/en/bridge). You can refer to the Binance Academy article "[How to Get Started with BSC](https://academy.binance.com/en/articles/how-to-get-started-with-binance-smart-chain-bsc)" for more information.