mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
commit
ecff81f61e
@ -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.
|
||||
|
||||
|
@ -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**
|
||||
|
||||
@ -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**
|
||||
@ -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**
|
||||
|
||||
|
@ -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! 🤯
|
||||
|
||||
|
@ -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,9 +79,6 @@ 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")
|
||||
|
||||
@ -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"
|
||||
|
||||
|
@ -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.
|
||||
@ -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**
|
||||
|
||||
|
@ -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**
|
||||
|
||||
|
@ -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,69 +19,15 @@ Here, we will:
|
||||
|
||||
Let's go!
|
||||
|
||||
### 1. Configure Brownie Networks (One-Time)
|
||||
### 1. Configure Networks
|
||||
|
||||
#### 1.1 Network config file
|
||||
#### 1.1 Define network RPC URLs
|
||||
|
||||
Brownie's network config file is `network-config.yaml`. It is located in the `.brownie/` subfolder of your home folder.
|
||||
To define the RPC URL for a network, simply add an env variable like `NETWORKNAME_RPC_URL` e.g. `export POLYGON_RPC_URL=https://polygon-rpc.com`
|
||||
|
||||
* For Linux & MacOS, it's: `~/.brownie/network-config.yaml`
|
||||
* For Windows users, it's: `C:\Users\<user_name>\.brownie\network-config.yaml`
|
||||
All [Ocean chain deployments](https://docs.oceanprotocol.com/discover/networks) (Eth mainnet, Polygon, etc) are supported.
|
||||
|
||||
#### 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.
|
||||
|
||||
@ -96,24 +42,7 @@ The config file's default RPCs point to Infura, which require you to have an Inf
|
||||
|
||||
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.
|
||||
By default, if `WEB3_INFURA_PROJECT_ID` is defined, ocean.py will glue that into place inside the RPC URL.
|
||||
|
||||
### 2. Create EVM Accounts (One-Time)
|
||||
|
||||
@ -217,17 +146,16 @@ ocean = Ocean(config)
|
||||
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 +163,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`.
|
||||
|
Loading…
Reference in New Issue
Block a user