Ocean.js 0.9.18

JavaScript client library for Ocean Protocol

Ocean

Main interface for Ocean Protocol.

network

Property
Network instance
src/ocean/Ocean.ts#L89

provider

Property
Provider instance.
src/ocean/Ocean.ts#L95

web3Provider

Property
Web3 provider.
any
src/ocean/Ocean.ts#L101

metadatacache

Property
MetadataCache instance.
src/ocean/Ocean.ts#L107

OnChainMetadataCache

Property
OnChainMetadataCache instance.
src/ocean/Ocean.ts#L112

accounts

Property
Ocean account submodule
src/ocean/Ocean.ts#L117

assets

Property
Ocean assets submodule
src/ocean/Ocean.ts#L130

compute

Property
Ocean compute submodule
src/ocean/Ocean.ts#L136

datatokens

Property
Ocean DataTokens submodule
src/ocean/Ocean.ts#L142

pool

Property
Ocean Pools submodule
src/ocean/Ocean.ts#L148

fixedRateExchange

Property
Ocean FixedRateExchange submodule
src/ocean/Ocean.ts#L154

versions

Property
Ocean versions submodule
src/ocean/Ocean.ts#L167

utils

Property
Ocean utils submodule
src/ocean/Ocean.ts#L173

Account

Account information.

getId

Method

Returns

string
src/ocean/Account.ts#L19

setId

Method

Parameters

id
string

Returns

void
src/ocean/Account.ts#L23

setPassword

Method
Set account password.

Parameters

password
string

Password for account.

Returns

void
src/ocean/Account.ts#L31

getPassword

Method
Returns account password.

Returns

string
src/ocean/Account.ts#L39

getTokenBalance

Method
Balance of Any Token (converted from wei).

Parameters

TokenAdress
string

Returns

Promise<
string
>
src/ocean/Account.ts#L82

getOceanBalance

Method
Balance of Ocean Token. (converted from wei).

Returns

Promise<
string
>
src/ocean/Account.ts#L123

getTokenSymbol

Method
Symbol of a Token

Parameters

TokenAdress
string

Returns

Promise<
string
>
src/ocean/Account.ts#L131

getEtherBalance

Method
Balance of Ether.(converted from wei).

Returns

Promise<
string
>
src/ocean/Account.ts#L140

Assets

Assets submodule of Ocean Protocol.

create

Method
Creates a new DDO and publishes it

Parameters

metadata

DDO metadata.

publisher

Publisher account.

services

list of Service description documents

dtAddress?
string

existing Data Token Address

cap?
string

Maximum cap (Number) - will be converted to wei

name?
string

Token name

symbol?
string

Token symbol

providerUri?
string

src/ocean/Assets.ts#L69

ownerAssets

Method
Returns the assets of a owner.

Parameters

owner
string

Owner address.

Returns

Promise<>
src/ocean/Assets.ts#L209

resolve

Method
Returns a DDO by DID.

Parameters

did
string

Decentralized ID.

Returns

Promise<>
src/ocean/Assets.ts#L218

resolveByDTAddress

Method

Parameters

dtAddress
string

offset?
number

page?
number

sort?
number

Returns

Promise<
DDO[]
>
src/ocean/Assets.ts#L222

editMetadata

Method
Edit Metadata for a DDO.

Parameters

did
string

newMetadata

account

Ethereum account of owner to sign and prove the ownership.

Returns

Promise<>
src/ocean/Assets.ts#L249

updateComputePrivacy

Method
Update Compute Privacy

Parameters

did
string

serviceIndex
number

Index of the compute service in the DDO

computePrivacy

ComputePrivacy fields & new values.

account

Ethereum account of owner to sign and prove the ownership.

Returns

Promise<>
src/ocean/Assets.ts#L296

creator

Method
Returns the creator of a asset.

Parameters

did
string

Decentralized ID.

Returns

Promise<
string
>
src/ocean/Assets.ts#L324

query

Method
Search over the assets using a query.

Parameters

query

Query to filter the assets.

Returns

Promise<>
src/ocean/Assets.ts#L344

getServiceByType

Method

Parameters

did
string

serviceType
string

Returns

Promise<>
src/ocean/Assets.ts#L367

getServiceByIndex

Method

Parameters

did
string

serviceIndex
number

Returns

Promise<>
src/ocean/Assets.ts#L379

createAccessServiceAttributes

Method
Creates an access service

Parameters

creator

cost
string

number of datatokens needed for this service

datePublished
string

timeout
number

providerUri?
string

Returns

Promise<>
src/ocean/Assets.ts#L399

initialize

Method
Initialize a service Can be used to compute totalCost for ordering a service

Parameters

did
string

serviceType
string

consumerAddress
string

serviceIndex
number

serviceEndpoint
string

Returns

Promise<
any
>
src/ocean/Assets.ts#L432

order

Method
Orders & pays for a service

Parameters

did
string

serviceType
string

payerAddress
string

serviceIndex
number

mpAddress?
string

Marketplace fee collector address

consumerAddress?
string

Optionally, if the consumer is another address than payer

Returns

Promise<
string
>
src/ocean/Assets.ts#L457

download

Method

Parameters

did
string

txId
string

tokenAddress
string

consumerAccount

destination
string

Returns

Promise<
>
src/ocean/Assets.ts#L523

simpleDownload

Method

Parameters

dtAddress
string

serviceEndpoint
string

txId
string

account
string

Returns

Promise<
string
>
src/ocean/Assets.ts#L563

getOrderHistory

Method
get Order History

Parameters

account

serviceType?
string

Optional, filter by

fromBlock?
number

Optional, start at block

Returns

Promise<>
src/ocean/Assets.ts#L591

Compute

Compute submodule of Ocean Protocol.

start

Method
Start the execution of a compute job.

Parameters

did
string

Decentralized identifer for the asset

txId
string

tokenAddress
string

consumerAccount

The account of the consumer ordering the service.

algorithmDid?
string

The DID of the algorithm asset (of type `algorithm`) to run on the asset.

algorithmMeta?

Metadata about the algorithm being run if `algorithm` is being used. This is ignored when `algorithmDid` is specified.

output?

Define algorithm output publishing. Publishing the result of a compute job is turned off by default.

serviceIndex?
string

serviceType?
string

algorithmTransferTxId?
string

algorithmDataToken?
string

Returns

Promise<>
src/ocean/Compute.ts#L77

stop

Method
Ends a running compute job.

Parameters

consumerAccount

The account of the consumer ordering the service.

did
string

Decentralized identifier.

jobId
string

The ID of the compute job to be stopped

Returns

Promise<>
src/ocean/Compute.ts#L123

delete

Method
Deletes a compute job and all resources associated with the job. If job is running it will be stopped first.

Parameters

consumerAccount

The account of the consumer ordering the service.

did
string

Decentralized identifier.

jobId
string

The ID of the compute job to be stopped

Returns

Promise<>
src/ocean/Compute.ts#L152

status

Method
Returns information about the status of all compute jobs, or a single compute job.

Parameters

consumerAccount

The account of the consumer ordering the service.

did?
string

Decentralized identifier.

jobId?
string

The Order transaction id

txId?
string

sign
boolean

If the provider request is going to be signed(default) (full status) or not (short status)

Returns

Promise<>
src/ocean/Compute.ts#L183

result

Method
Returns the final result of a specific compute job published as an asset.

Parameters

consumerAccount

The account of the consumer ordering the service.

did
string

Decentralized identifier.

jobId
string

The ID of the compute job to be stopped.

Returns

Promise<>
src/ocean/Compute.ts#L228

createServerAttributes

Method

Parameters

serverId
string

serverType
string

cost
string

cpu
string

gpu
string

memory
string

disk
string

maxExecutionTime
number

Returns

src/ocean/Compute.ts#L250

createContainerAttributes

Method

Parameters

image
string

tag
string

checksum
string

Returns

src/ocean/Compute.ts#L272

createClusterAttributes

Method

Parameters

type
string

url
string

Returns

src/ocean/Compute.ts#L280

createProviderAttributes

Method

Parameters

type
string

description
string

cluster

containers

servers

Returns

src/ocean/Compute.ts#L284

createComputeService

Method
Creates a compute service

Parameters

consumerAccount

cost
string

number of datatokens needed for this service, expressed in wei

datePublished
string

providerAttributes
any

computePrivacy?

timeout?
number

providerUri?
string

src/ocean/Compute.ts#L320

order

Method
Starts an order of a compute service that is defined in an asset's services.

Parameters

consumerAccount
string

The account of the consumer ordering the service.

datasetDid
string

The DID of the dataset asset (of type `dataset`) to run the algorithm on.

serviceIndex
number

The Service index

algorithmDid?
string

The DID of the algorithm asset (of type `algorithm`) to run on the asset.

algorithmMeta?

Metadata about the algorithm being run if `algorithm` is being used. This is ignored when `algorithmDid` is specified.

mpAddress?
string

src/ocean/Compute.ts#L392

Versions

Versions submodule of Ocean Protocol.

DID

Decentralized ID.

getDid

Method
Returns the DID.

Returns

string
src/ocean/DID.ts#L53

getId

Method
Returns the ID.

Returns

string
src/ocean/DID.ts#L61

DDO

DID Descriptor Object. Contains all the data related to an asset.

@context

Property
string
src/ddo/DDO.ts#L35

id

Property
DID, descentralized ID.
string
src/ddo/DDO.ts#L41

created

Property
string
src/ddo/DDO.ts#L43

updated

Property
string
src/ddo/DDO.ts#L45

dataToken

Property
string
src/ddo/DDO.ts#L47

publicKey

Property
src/ddo/DDO.ts#L49

authentication

Property
src/ddo/DDO.ts#L51

service

Property
src/ddo/DDO.ts#L53

isInPurgatory

Property
src/ddo/DDO.ts#L59

purgatoryData

Property
src/ddo/DDO.ts#L61

dataTokenInfo

Property
src/ddo/DDO.ts#L63

shortId

Method

Returns

string
src/ddo/DDO.ts#L71

findServiceById

Method
Finds a service of a DDO by index.

Parameters

index
number

Returns

src/ddo/DDO.ts#L80

findServiceByType

Method
Finds a service of a DDO by type.

Parameters

serviceType
T

Service type.

Returns

src/ddo/DDO.ts#L95

getChecksum

Method
Generate the checksum using the current content.

Returns

string
src/ddo/DDO.ts#L107

addProof

Method
Generates and adds a simple hash proof on publicKey

Parameters

ocean

Ocean instance.

publicKey
string

Public key to be used on personal sign.

password?
string

Returns

Promise<
void
>
src/ddo/DDO.ts#L133

MetadataCache

Provides an interface with Metadata Cache. Metadata Cache provides an off-chain database cache for on-chain metadata about data assets.

getVersionInfo

Method

Returns

Promise<
any
>
src/metadatacache/MetadataCache.ts#L49

getAccessUrl

Method

Parameters

accessToken
any

payload
any

Returns

Promise<
string
>
src/metadatacache/MetadataCache.ts#L53

queryMetadata

Method
Search over the DDOs using a query.

Parameters

query

Query to filter the DDOs.

Returns

Promise<>
src/metadatacache/MetadataCache.ts#L80

storeDDO

Method
Stores a DDO in Metadata Store.

Parameters

ddo

DDO to be stored.

Returns

Promise<>
src/metadatacache/MetadataCache.ts#L106

retrieveDDO

Method
Retrieves a DDO by DID.

Parameters

did

DID of the asset.

metadataServiceEndpoint?
string

Returns

Promise<>
src/metadatacache/MetadataCache.ts#L133

retrieveDDOByUrl

Method

Parameters

metadataServiceEndpoint?
string

Returns

Promise<>
src/metadatacache/MetadataCache.ts#L159

transferOwnership

Method
Transfer ownership of a DDO

Parameters

did

DID of the asset to update.

newOwner
string

New owner of the DDO

updated
string

Updated field of the DDO

signature
string

Signature using updated field to verify that the consumer has rights

Returns

Promise<
string
>
src/metadatacache/MetadataCache.ts#L171

updateComputePrivacy

Method
Update Compute Privacy

Parameters

did

DID of the asset to update.

serviceIndex
number

Service index

allowRawAlgorithm
boolean

Allow Raw Algorithms

allowNetworkAccess
boolean

Allow Raw Algorithms

trustedAlgorithms
string[]

Allow Raw Algorithms

updated
string

Updated field of the DDO

signature
string

Signature using updated field to verify that the consumer has rights

Returns

Promise<
string
>
src/metadatacache/MetadataCache.ts#L215

getOwnerAssets

Method

Parameters

owner
string

Returns

Promise<>
src/metadatacache/MetadataCache.ts#L258

editMetadata

Method
Edit Metadata for a DDO.

Parameters

did

newMetadata

updated
string

Updated field of the DDO

signature
string

Signature using updated field to verify that the consumer has rights

Returns

Promise<
string
>
src/metadatacache/MetadataCache.ts#L282

retire

Method
Retire a DDO (Delete)

Parameters

did

DID of the asset to update.

updated
string

Updated field of the DDO

signature
string

Signature using updated field to verify that the consumer has rights

Returns

Promise<
string
>
src/metadatacache/MetadataCache.ts#L322

getServiceEndpoint

Method

Parameters

did

Returns

string
src/metadatacache/MetadataCache.ts#L353

OnChainMetadataCache

Provides an interface with Metadata Cache. Metadata Cache provides an off-chain database store for metadata about data assets.

GASLIMIT_DEFAULT

Property
number
src/metadatacache/OnChainMetaDataCache.ts#L17

DDOContractAddress

Property
string
src/metadatacache/OnChainMetaDataCache.ts#L18

compressDDO

Method
Compress DDO using xz/lzma2

Parameters

ddo

Returns

Promise<
string
>
src/metadatacache/OnChainMetaDataCache.ts#L47

publish

Method
Publish a new DDO

Parameters

did
string

ddo

consumerAccount
string

Returns

Promise<
TransactionReceipt
>
src/metadatacache/OnChainMetaDataCache.ts#L62

update

Method
Update DDO

Parameters

did
string

ddo

consumerAccount
string

Returns

Promise<
TransactionReceipt
>
src/metadatacache/OnChainMetaDataCache.ts#L80

publishRaw

Method
Raw publish ddo

Parameters

did
string

flags
any

data
any

consumerAccount
string

Returns

Promise<
TransactionReceipt
>
src/metadatacache/OnChainMetaDataCache.ts#L99

updateRaw

Method
Raw update of a ddo

Parameters

did
string

flags
any

data
any

consumerAccount
string

Returns

Promise<
TransactionReceipt
>
src/metadatacache/OnChainMetaDataCache.ts#L141

transferOwnership

Method
Transfer Ownership of a DDO

Parameters

did
string

newOwner
string

consumerAccount
string

Returns

Promise<
TransactionReceipt
>
src/metadatacache/OnChainMetaDataCache.ts#L182

getHex

Method

Parameters

message
any

Returns

string
src/metadatacache/OnChainMetaDataCache.ts#L201

Provider

Provides an interface for provider service. Provider service is the technical component executed by the Publishers allowing to them to provide extended data services.

nonce

Property
string
src/provider/Provider.ts#L21

setBaseUrl

Method

Parameters

url
string

Returns

void
src/provider/Provider.ts#L35

createSignature

Method

Parameters

account

agreementId
string

Returns

Promise<
string
>
src/provider/Provider.ts#L39

createHashSignature

Method

Parameters

account

message
string

Returns

Promise<
string
>
src/provider/Provider.ts#L48

encrypt

Method

Parameters

did
string

document
any

account

Returns

Promise<
string
>
src/provider/Provider.ts#L57

getNonce

Method
Get nonce from provider

Parameters

consumerAddress
string

Returns

Promise<
string
>
src/provider/Provider.ts#L80

initialize

Method

Parameters

did
string

serviceIndex
number

serviceType
string

consumerAddress
string

Returns

Promise<
string
>
src/provider/Provider.ts#L93

download

Method

Parameters

did
string

txId
string

tokenAddress
string

serviceType
string

serviceIndex
string

destination
string

account

files

index
number

Returns

Promise<
any
>
src/provider/Provider.ts#L123

compute

Method

Parameters

method
string

did
string

consumerAccount

algorithmDid?
string

algorithmMeta?

jobId?
string

output?

txId?
string

serviceIndex?
string

serviceType?
string

tokenAddress?
string

algorithmTransferTxId?
string

algorithmDataToken?
string

sign
boolean

Returns

Promise<
>
src/provider/Provider.ts#L161

getVersionInfo

Method

Returns

Promise<>
src/provider/Provider.ts#L254

getURI

Method

Returns

string
src/provider/Provider.ts#L258

getInitializeEndpoint

Method

Returns

string
src/provider/Provider.ts#L262

getNonceEndpoint

Method

Returns

string
src/provider/Provider.ts#L266

getConsumeEndpointPath

Method

Returns

string
src/provider/Provider.ts#L270

getConsumeEndpoint

Method

Returns

string
src/provider/Provider.ts#L274

getEncryptEndpoint

Method

Returns

string
src/provider/Provider.ts#L278

getPublishEndpoint

Method

Returns

string
src/provider/Provider.ts#L282

getComputeEndpointPath

Method

Returns

string
src/provider/Provider.ts#L286

getComputeEndpoint

Method

Returns

string
src/provider/Provider.ts#L290

getDownloadEndpoint

Method

Returns

string
src/provider/Provider.ts#L294

isValidProvider

Method
Check for a valid provider at URL

Parameters

url
string

Returns

Promise<
boolean
>
src/provider/Provider.ts#L302

DataTokens

Provides an interface to DataTokens

GASLIMIT_DEFAULT

Property
number
src/datatokens/Datatokens.ts#L15

factoryAddress

Property
string
src/datatokens/Datatokens.ts#L16

generateDtName

Method
Generate new datatoken name & symbol from a word list

Parameters

wordList?

Returns

src/datatokens/Datatokens.ts#L46

create

Method
Create new datatoken

Parameters

metadataCacheUri
string

address
string

cap?
string

Maximum cap (Number) - will be converted to wei

name?
string

Token name

symbol?
string

Token symbol

Returns

Promise<
string
>
src/datatokens/Datatokens.ts#L77

approve

Method
Approve

Parameters

dataTokenAddress
string

spender
string

amount
string

Number of datatokens, as number. Will be converted to wei

address
string

Returns

Promise<
TransactionReceipt
>
src/datatokens/Datatokens.ts#L131

mint

Method
Mint

Parameters

dataTokenAddress
string

address
string

amount
string

Number of datatokens, as number. Will be converted to wei

toAddress?
string

only if toAddress is different from the minter

Returns

Promise<
TransactionReceipt
>
src/datatokens/Datatokens.ts#L167

transfer

Method
Transfer as number from address to toAddress

Parameters

dataTokenAddress
string

toAddress
string

amount
string

Number of datatokens, as number. Will be converted to wei

address
string

Returns

Promise<
TransactionReceipt
>
src/datatokens/Datatokens.ts#L205

transferToken

Method
Transfer as number from address to toAddress

Parameters

dataTokenAddress
string

toAddress
string

amount
string

Number of datatokens, as number. Will be converted to wei

address
string

Returns

Promise<
TransactionReceipt
>
src/datatokens/Datatokens.ts#L222

transferWei

Method
Transfer in wei from address to toAddress

Parameters

dataTokenAddress
string

toAddress
string

amount
string

Number of datatokens, as number. Expressed as wei

address
string

Returns

Promise<
TransactionReceipt
>
src/datatokens/Datatokens.ts#L240

transferFrom

Method
Transfer from fromAddress to address (needs an Approve operation before)

Parameters

dataTokenAddress
string

fromAddress
string

amount
string

Number of datatokens, as number. Will be converted to wei

address
string

Returns

Promise<
string
>
src/datatokens/Datatokens.ts#L274

balance

Method
Get Address Balance for datatoken

Parameters

dataTokenAddress
string

address
string

Returns

Promise<
string
>
src/datatokens/Datatokens.ts#L308

allowance

Method
Get Alloance

Parameters

dataTokenAddress
string

owner
string

spender
string

Returns

Promise<
string
>
src/datatokens/Datatokens.ts#L322

getBlob

Method
Get Blob

Parameters

dataTokenAddress
string

Returns

Promise<
string
>
src/datatokens/Datatokens.ts#L338

getName

Method
Get Name

Parameters

dataTokenAddress
string

Returns

Promise<
string
>
src/datatokens/Datatokens.ts#L348

getSymbol

Method
Get Symbol

Parameters

dataTokenAddress
string

Returns

Promise<
string
>
src/datatokens/Datatokens.ts#L358

getCap

Method
Get Cap

Parameters

dataTokenAddress
string

Returns

Promise<
string
>
src/datatokens/Datatokens.ts#L368

toWei

Method
Convert to wei

Parameters

amount
string

Returns

string
src/datatokens/Datatokens.ts#L378

fromWei

Method
Convert from wei

Parameters

amount
string

Returns

string
src/datatokens/Datatokens.ts#L386

startOrder

Method
Start Order

Parameters

dataTokenAddress
string

consumer
string

consumer Address

amount
string

serviceId
number

mpFeeAddress
string

address
string

consumer Address

Returns

Promise<
TransactionReceipt
>
src/datatokens/Datatokens.ts#L399

getPreviousValidOrders

Method
Search and return txid for a previous valid order with the same params

Parameters

dataTokenAddress
string

amount
string

serviceId
number

timeout
number

service timeout

address
string

consumer Address

Returns

Promise<
string
>
src/datatokens/Datatokens.ts#L454

getStartOrderEventSignature

Method

Returns

string
src/datatokens/Datatokens.ts#L485

Network

getNetworkId

Method
Returns network id.

Returns

Promise<
number
>
src/datatokens/Network.ts#L9

getNetworkName

Method
Returns the network by name.

Returns

Promise<
string
>
src/datatokens/Network.ts#L17

Web3Provider

OceanPool

Ocean Pools submodule exposed under ocean.pool

oceanAddress

Property
string
src/balancer/OceanPool.ts#L56

dtAddress

Property
string
src/balancer/OceanPool.ts#L57

startBlock

Property
number
src/balancer/OceanPool.ts#L58

create

Method
Create DataToken pool

Parameters

account
string

dtAddress
string

DataToken address

dtAmount
string

DataToken amount

dtWeight
string

DataToken weight

oceanAmount
string

Ocean amount

fee
string

Swap fee. E.g. to get a 0.1% swapFee use `0.001`. The maximum allowed swapFee is `0.1` (10%).

Returns

src/balancer/OceanPool.ts#L87

getDTAddress

Method
Get DataToken address of token in this pool

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L170

getOceanReserve

Method
Get Ocean Token balance of a pool

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L188

getDTReserve

Method
Get datatoken balance of a pool

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L201

getMaxBuyQuantity

Method
Returns max amount that you can buy.

Parameters

poolAddress
string

tokenAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L211

getOceanMaxBuyQuantity

Method
Returns max amount of OCEAN that you can buy.

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L224

getDTMaxBuyQuantity

Method
Returns max amount of DT that you can buy.

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L233

calcInGivenOut

Method
Returns tokenInAmount required to get tokenOutAmount

Parameters

poolAddress
string

tokenInAddress
string

tokenOutAddress
string

tokenOutAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L244

calcOutGivenIn

Method
Returns tokenOutAmount given tokenInAmount

Parameters

poolAddress
string

tokenInAddress
string

tokenOutAddress
string

tokenInAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L270

calcPoolOutGivenSingleIn

Method
Returns no of shares receved for adding a token to the pool

Parameters

poolAddress
string

tokenInAddress
string

tokenInAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L295

calcSingleInGivenPoolOut

Method
Returns no of tokens required to get a specific no of poolShares

Parameters

poolAddress
string

tokenInAddress
string

poolShares
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L318

calcSingleOutGivenPoolIn

Method
Returns no of tokens received for spending a specific no of poolShares

Parameters

poolAddress
string

tokenOutAddress
string

poolShares
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L341

calcPoolInGivenSingleOut

Method
Returns no of pool shares required to receive a specified amount of tokens

Parameters

poolAddress
string

tokenOutAddress
string

tokenOutAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L364

getPoolSharesRequiredToRemoveDT

Method
Returns no of pool shares required to receive specified amount of DT

Parameters

poolAddress
string

dtAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L386

getDTRemovedforPoolShares

Method
Returns DT amnount received after spending poolShares

Parameters

poolAddress
string

poolShares
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L399

getPoolSharesRequiredToRemoveOcean

Method
Returns no of pool shares required to receive specified amount of DT

Parameters

poolAddress
string

oceanAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L412

getOceanRemovedforPoolShares

Method
Returns Ocean amnount received after spending poolShares

Parameters

poolAddress
string

poolShares
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L424

getTokensRemovedforPoolShares

Method
Returns Datatoken & Ocean amounts received after spending poolShares

Parameters

poolAddress
string

poolShares
string

Returns

src/balancer/OceanPool.ts#L437

getDTMaxAddLiquidity

Method
Returns max DT amount that you can add to the pool

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L463

getOceanMaxAddLiquidity

Method
Returns max Ocean amount that you can add to the pool

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L472

getMaxAddLiquidity

Method
Returns max amount of tokens that you can add to the pool

Parameters

poolAddress
string

tokenAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L481

getMaxRemoveLiquidity

Method
Returns max amount of tokens that you can withdraw from the pool

Parameters

poolAddress
string

tokenAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L500

getDTMaxRemoveLiquidity

Method
Returns max amount of DT that you can withdraw from the pool

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L519

getOceanMaxRemoveLiquidity

Method
Returns max amount of Ocean that you can withdraw from the pool

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L529

buyDT

Method
Buy datatoken from a pool

Parameters

account
string

poolAddress
string

dtAmountWanted
string

maxOceanAmount
string

maxPrice?
string

Maximum price to pay

Returns

Promise<
TransactionReceipt
>
src/balancer/OceanPool.ts#L542

buyDTWithExactOcean

Method
Buy at least datatoken from a pool for a fixed Ocean amount

Parameters

account
string

poolAddress
string

minimumdtAmountWanted
string

OceanAmount
string

maxPrice?
string

Maximum price to pay

Returns

Promise<
TransactionReceipt
>
src/balancer/OceanPool.ts#L598

sellDT

Method
Sell a specific amount of datatoken to get some ocean tokens

Parameters

account
string

poolAddress
string

dtAmount
string

oceanAmountWanted
string

maxPrice?
string

Minimum price to sell

Returns

Promise<
TransactionReceipt
>
src/balancer/OceanPool.ts#L655

addDTLiquidity

Method
Add datatoken amount to pool liquidity

Parameters

account
string

poolAddress
string

amount
string

datatoken amount

Returns

Promise<
TransactionReceipt
>
src/balancer/OceanPool.ts#L709

removeDTLiquidity

Method
Remove datatoken amount from pool liquidity

Parameters

account
string

poolAddress
string

amount
string

datatoken amount

maximumPoolShares
string

Returns

Promise<
TransactionReceipt
>
src/balancer/OceanPool.ts#L747

addOceanLiquidity

Method
Add Ocean Token amount to pool liquidity

Parameters

account
string

poolAddress
string

amount
string

Ocean Token amount in OCEAN

Returns

Promise<
TransactionReceipt
>
src/balancer/OceanPool.ts#L789

removeOceanLiquidity

Method
Remove Ocean Token amount from pool liquidity

Parameters

account
string

poolAddress
string

amount
string

Ocean Token amount in OCEAN

maximumPoolShares
string

Returns

Promise<
TransactionReceipt
>
src/balancer/OceanPool.ts#L830

removePoolLiquidity

Method
Remove pool liquidity

Parameters

account
string

poolAddress
string

poolShares
string

Minim Ocean expected (defaults 0)

minDT
string

Minimum DT expected (defaults 0)

minOcean
string

Returns

Promise<
TransactionReceipt
>
src/balancer/OceanPool.ts#L880

getDTPrice

Method
Get datatoken price from pool

Parameters

poolAddress
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L904

searchPoolforDT

Method
Search all pools that have datatoken in their composition

Parameters

dtAddress
string

Returns

Promise<
string[]
>
src/balancer/OceanPool.ts#L917

getOceanNeeded

Method

Parameters

poolAddress
string

dtRequired
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L933

getOceanReceived

Method
Calculate how many Ocean Tokens are you going to receive for selling a specific dtAmount (selling DT)

Parameters

poolAddress
string

dtAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L949

getDTReceived

Method
Calculate how many data token are you going to receive for selling a specific oceanAmount (buying DT)

Parameters

poolAddress
string

oceanAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L960

getDTNeeded

Method

Parameters

poolAddress
string

OceanRequired
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L965

getPoolsbyCreator

Method
Search all pools created by an address

Parameters

account?
string

If empty, will return all pools ever created by anybody

Returns

Promise<>
src/balancer/OceanPool.ts#L981

getPoolSharesByAddress

Method
Search all pools in which a user has shares

Parameters

account
string

Returns

Promise<>
src/balancer/OceanPool.ts#L1017

getPoolDetails

Method
Get pool details

Parameters

poolAddress
string

Pool address

Returns

Promise<>
src/balancer/OceanPool.ts#L1055

getPoolLogs

Method
Get all actions from a pool (join,exit,swap)

Parameters

poolAddress
string

Pool address

startBlock
number

account?
string

Optional, filter for this address

Returns

Promise<>
src/balancer/OceanPool.ts#L1067

getAllPoolLogs

Method
Get all logs on all pools for a specific address

Parameters

account
string

Returns

Promise<>
src/balancer/OceanPool.ts#L1132

computeBuySlippage

Method

Parameters

poolAddress
string

oceanAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L1261

computeSellSlippage

Method

Parameters

poolAddress
string

dtAmount
string

Returns

Promise<
string
>
src/balancer/OceanPool.ts#L1300

calcSpotPrice

Method

Parameters

poolAddress
string

tokenBalanceIn
string

tokenWeightIn
string

tokenBalanceOut
string

tokenWeightOut
string

swapFee
string

Returns

Promise<
string
>
src/balancer/Pool.ts#L981

getSwapEventSignature

Method
Get LOG_SWAP encoded topic

Returns

string
src/balancer/Pool.ts#L1187

getJoinEventSignature

Method
Get LOG_JOIN encoded topic

Returns

string
src/balancer/Pool.ts#L1200

getExitEventSignature

Method
Get LOG_EXIT encoded topic

Returns

string
src/balancer/Pool.ts#L1213

GASLIMIT_DEFAULT

Property
number
src/balancer/PoolFactory.ts#L8

factoryAddress

Property
string
src/balancer/PoolFactory.ts#L11

Pool

calcSpotPrice

Method

Parameters

poolAddress
string

tokenBalanceIn
string

tokenWeightIn
string

tokenBalanceOut
string

tokenWeightOut
string

swapFee
string

Returns

Promise<
string
>
src/balancer/Pool.ts#L981

calcInGivenOut

Method

Parameters

poolAddress
string

tokenBalanceIn
string

tokenWeightIn
string

tokenBalanceOut
string

tokenWeightOut
string

tokenAmountOut
string

swapFee
string

Returns

Promise<
string
>
src/balancer/Pool.ts#L1008

calcOutGivenIn

Method

Parameters

poolAddress
string

tokenBalanceIn
string

tokenWeightIn
string

tokenBalanceOut
string

tokenWeightOut
string

tokenAmountIn
string

swapFee
string

Returns

Promise<
string
>
src/balancer/Pool.ts#L1038

calcPoolOutGivenSingleIn

Method

Parameters

poolAddress
string

tokenBalanceIn
string

tokenWeightIn
string

poolSupply
string

totalWeight
string

tokenAmountIn
string

swapFee
string

Returns

Promise<
string
>
src/balancer/Pool.ts#L1067

calcSingleInGivenPoolOut

Method

Parameters

poolAddress
string

tokenBalanceIn
string

tokenWeightIn
string

poolSupply
string

totalWeight
string

poolAmountOut
string

swapFee
string

Returns

Promise<
string
>
src/balancer/Pool.ts#L1096

calcSingleOutGivenPoolIn

Method

Parameters

poolAddress
string

tokenBalanceOut
string

tokenWeightOut
string

poolSupply
string

totalWeight
string

poolAmountIn
string

swapFee
string

Returns

Promise<
string
>
src/balancer/Pool.ts#L1125

calcPoolInGivenSingleOut

Method

Parameters

poolAddress
string

tokenBalanceOut
string

tokenWeightOut
string

poolSupply
string

totalWeight
string

tokenAmountOut
string

swapFee
string

Returns

Promise<
string
>
src/balancer/Pool.ts#L1154

getSwapEventSignature

Method
Get LOG_SWAP encoded topic

Returns

string
src/balancer/Pool.ts#L1187

getJoinEventSignature

Method
Get LOG_JOIN encoded topic

Returns

string
src/balancer/Pool.ts#L1200

getExitEventSignature

Method
Get LOG_EXIT encoded topic

Returns

string
src/balancer/Pool.ts#L1213

GASLIMIT_DEFAULT

Property
number
src/balancer/PoolFactory.ts#L8

factoryAddress

Property
string
src/balancer/PoolFactory.ts#L11

PoolFactory

GASLIMIT_DEFAULT

Property
number
src/balancer/PoolFactory.ts#L8

factoryAddress

Property
string
src/balancer/PoolFactory.ts#L11

OceanFixedRateExchange

GASLIMIT_DEFAULT

Property
number
src/exchange/FixedRateExchange.ts#L33

oceanAddress

Property
Ocean related functions
string
src/exchange/FixedRateExchange.ts#L35

fixedRateExchangeAddress

Property
string
src/exchange/FixedRateExchange.ts#L36

fixedRateExchangeABI

Property
src/exchange/FixedRateExchange.ts#L37

create

Method
Creates new exchange pair between Ocean Token and data token.

Parameters

dataToken
string

Data Token Contract Address

rate
string

exchange rate

address
string

User address

amount?
string

Optional, amount of datatokens to be approved for the exchange

src/exchange/FixedRateExchange.ts#L84

generateExchangeId

Method
Creates unique exchange identifier.

Parameters

dataToken
string

Data Token Contract Address

owner
string

Owner of the exchange

Returns

Promise<
string
>
src/exchange/FixedRateExchange.ts#L129

buyDT

Method
Atomic swap

Parameters

exchangeId
string

ExchangeId

dataTokenAmount
string

Amount of Data Tokens

address
string

User address

Returns

Promise<
TransactionReceipt
>
src/exchange/FixedRateExchange.ts#L143

getNumberOfExchanges

Method
Gets total number of exchanges

Returns

Promise<
number
>
src/exchange/FixedRateExchange.ts#L178

setRate

Method
Set new rate

Parameters

exchangeId
string

ExchangeId

newRate
number

New rate

address
string

User account

Returns

Promise<
TransactionReceipt
>
src/exchange/FixedRateExchange.ts#L190

activate

Method
Activate an exchange

Parameters

exchangeId
string

ExchangeId

address
string

User address

Returns

Promise<
TransactionReceipt
>
src/exchange/FixedRateExchange.ts#L220

deactivate

Method
Deactivate an exchange

Parameters

exchangeId
string

ExchangeId

address
string

User address

Returns

Promise<
TransactionReceipt
>
src/exchange/FixedRateExchange.ts#L250

getRate

Method
Get Rate

Parameters

exchangeId
string

ExchangeId

Returns

Promise<
string
>
src/exchange/FixedRateExchange.ts#L279

getSupply

Method
Get Supply

Parameters

exchangeId
string

ExchangeId

Returns

Promise<
string
>
src/exchange/FixedRateExchange.ts#L289

getOceanNeeded

Method
getOceanNeeded

Parameters

exchangeId
string

ExchangeId

dataTokenAmount
string

Amount of Data Tokens

Returns

Promise<
string
>
src/exchange/FixedRateExchange.ts#L300

getExchange

Method
Get exchange details

Parameters

exchangeId
string

ExchangeId

Returns

src/exchange/FixedRateExchange.ts#L315

getExchanges

Method
Get all exchanges

Returns

Promise<
string[]
>
src/exchange/FixedRateExchange.ts#L329

isActive

Method
Check if an exchange is active

Parameters

exchangeId
string

ExchangeId

Returns

Promise<
boolean
>
src/exchange/FixedRateExchange.ts#L338

CalcInGivenOut

Method
Calculates how many basetokens are needed to get specifyed amount of datatokens

Parameters

exchangeId
string

ExchangeId

dataTokenAmount
string

dataTokenAmount

Returns

Promise<
string
>
src/exchange/FixedRateExchange.ts#L349

searchforDT

Method

Parameters

dataTokenAddress
string

minSupply
string

Returns

src/exchange/FixedRateExchange.ts#L359

getExchangesbyCreator

Method
Get all exchanges, filtered by creator(if any)

Parameters

account?
string

Returns

src/exchange/FixedRateExchange.ts#L391

getExchangeSwaps

Method
Get all swaps for an exchange, filtered by account(if any)

Parameters

exchangeId
string

account?
string

Returns

Promise<>
src/exchange/FixedRateExchange.ts#L411

getAllExchangesSwaps

Method
Get all swaps for an account

Parameters

account
string

Returns

Promise<>
src/exchange/FixedRateExchange.ts#L433

Config

nodeUri

Property
Ethereum node URL.
string
src/models/Config.ts#L9

providerAddress

Property
Address of Provider.
string
src/models/Config.ts#L15

metadataCacheUri

Property
Metadata Store URL.
string
src/models/Config.ts#L21

providerUri

Property
Provider URL.
string
src/models/Config.ts#L27

web3Provider

Property
Web3 Provider.
any
src/models/Config.ts#L33

oceanTokenAddress

Property
Ocean Token address
string
src/models/Config.ts#L39

factoryAddress

Property
Factory address
string
src/models/Config.ts#L45

factoryABI

Property
Factory ABI
src/models/Config.ts#L51

datatokensABI

Property
datatokens ABI
src/models/Config.ts#L57

poolFactoryAddress

Property
Pool Factory address
string
src/models/Config.ts#L63

poolFactoryABI

Property
Pool Factory ABI
src/models/Config.ts#L69

poolABI

Property
Pool ABI
src/models/Config.ts#L75

fixedRateExchangeAddress

Property
FixedRateExchangeAddress
string
src/models/Config.ts#L81

fixedRateExchangeAddressABI

Property
FixedRateExchangeAddressABI
src/models/Config.ts#L87

metadataContractAddress

Property
DDOContractAddress
string
src/models/Config.ts#L92

metadataContractABI

Property
DDOContractABI
src/models/Config.ts#L98

startBlock

Property
block number of the deployment
number
src/models/Config.ts#L103

verbose

Property
Log level.
src/models/Config.ts#L108

authMessage

Property
Message shown when the user creates its own token.
string
src/models/Config.ts#L114

authTokenExpiration

Property
Token expiration time in ms.
number
src/models/Config.ts#L120

parityUri

Property
string
src/models/Config.ts#L123

threshold

Property
number
src/models/Config.ts#L125

ConfigHelper

getAddressesFromEnv

Method

Parameters

network
string

Returns

src/utils/ConfigHelper.ts#L77

getConfig

Method

Parameters

network

infuraProjectId?
string

Returns

src/utils/ConfigHelper.ts#L124

WebServiceConnector

Provides a common interface to web services.

post

Method

Parameters

url
string

payload
BodyInit

Returns

Promise<
Response
>
src/ocean/utils/WebServiceConnector.ts#L18

get

Method

Parameters

url
string

Returns

Promise<
Response
>
src/ocean/utils/WebServiceConnector.ts#L28

put

Method

Parameters

url
string

payload
BodyInit

Returns

Promise<
Response
>
src/ocean/utils/WebServiceConnector.ts#L37

delete

Method

Parameters

url
string

payload?
BodyInit

Returns

Promise<
Response
>
src/ocean/utils/WebServiceConnector.ts#L47

downloadFile

Method

Parameters

url
string

destination?
string

index?
number

Returns

Promise<
string
>
src/ocean/utils/WebServiceConnector.ts#L66

Logger

setLevel

Method

Parameters

logLevel

Returns

void
src/utils/Logger.ts#L12

bypass

Method

Parameters

args
any[]

Returns

void
src/utils/Logger.ts#L16

debug

Method

Parameters

args
any[]

Returns

void
src/utils/Logger.ts#L20

log

Method

Parameters

args
any[]

Returns

void
src/utils/Logger.ts#L24

warn

Method

Parameters

args
any[]

Returns

void
src/utils/Logger.ts#L28

error

Method

Parameters

args
any[]

Returns

void
src/utils/Logger.ts#L32