Configuration
For obtaining the API keys for blockchain access and setting the correct environment variables, please consult this section first and proceed with the next steps.
Create a directory
Let's start with creating a working directory where we store the environment variable file, configuration files, and the scripts.
Create a .env
file
.env
fileIn the working directory create a .env
file. The content of this file will store the values for the following variables:
OCEAN_NETWORK
Name of the network where the Ocean Protocol's smart contracts are deployed.
Yes
OCEAN_NETWORK_URL
The URL of the Ethereum node (along with API key for non-local networks)**
Yes
PRIVATE_KEY
The private key of the account which you want to use. A private key is made up of 64 hex characters. Make sure you have sufficient balance to pay for the transaction fees.
Yes
AQUARIUS_URL
The URL of the Aquarius. This value is needed when reading an asset from off-chain store.
No
PROVIDER_URL
The URL of the Provider. This value is needed when publishing a new asset or update an existing asset.
No
Treat this file as a secret and do not commit this file to git or share the content publicly. If you are using git, then include this file name in .gitignore
file.
The below tabs show partially filled .env
file content for some of the supported networks.
Replace <replace this>
with the appropriate values. You can see all the networks configuration on Oceanjs' config helper.
Setup dependencies
In this step, all required dependencies will be installed.
Installation & Usage
Let's install Ocean.js library into your current project by running:
Create a configuration file
A configuration file will read the content of the .env
file and initialize the required configuration objects which will be used in the further tutorials. The below scripts creates a Web3 wallet instance and an Ocean's configuration object.
Create the configuration file in the working directory i.e. at the same path where the .env
is located.
Now you have set up the necessary files and configurations to interact with Ocean Protocol's smart contracts using ocean.js. You can proceed with further tutorials or development using these configurations.
Last updated