Squid-js 2.0.0

JavaScript client library for Ocean Protocol

Ocean

Main interface for Ocean Protocol.

keeper

Property
Keeper instance.
src/ocean/Ocean.ts#L66

brizo

Property
Brizo instance.
src/ocean/Ocean.ts#L72

aquarius

Property
Aquarius instance.
src/ocean/Ocean.ts#L78

accounts

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

auth

Property
Ocean auth submodule
src/ocean/Ocean.ts#L90

assets

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

agreements

Property
Ocean agreements submodule
src/ocean/Ocean.ts#L102

compute

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

secretStore

Property
Ocean secretStore submodule
src/ocean/Ocean.ts#L114

tokens

Property
Ocean tokens submodule
src/ocean/Ocean.ts#L120

versions

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

utils

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

OceanAccounts

Account submodule of Ocean Protocol.

list

Method
Returns the list of accounts.

Returns

Promise<>
src/ocean/OceanAccounts.ts#L24

balance

Method
Return account balance.

Parameters

account

Account instance.

Returns

Promise<>
src/ocean/OceanAccounts.ts#L39

requestTokens

Method
Request tokens for an account.

Parameters

account

Account instance.

amount
number

Token amount.

Returns

Promise<
boolean
>
src/ocean/OceanAccounts.ts#L49

OceanAssets

Assets submodule of Ocean Protocol.

resolve

Method
Returns a DDO by DID.

Parameters

did
string

Decentralized ID.

Returns

Promise<>
src/ocean/OceanAssets.ts#L43

create

Method
Creates a new DDO.

Parameters

metadata

DDO metadata.

publisher

Publisher account.

services

list of Service description documents

src/ocean/OceanAssets.ts#L57

consume

Method

Parameters

agreementId
string

did
string

consumerAccount

resultPath
string

index?
number

useSecretStore?
boolean

Returns

Promise<
string
>
src/ocean/OceanAssets.ts#L198

order

Method
Start the purchase/order of an asset's service. Starts by signing the service agreement then sends the request to the publisher via the service endpoint (Brizo http service).

Parameters

did
string

Decentralized ID.

consumerAccount

Consumer account.

provider?
string

ethereum address of service provider (optional)

src/ocean/OceanAssets.ts#L285

owner

Method
Returns the owner of an asset.

Parameters

did
string

Decentralized ID.

Returns

Promise<
string
>
src/ocean/OceanAssets.ts#L313

ownerAssets

Method
Returns the assets of a owner.

Parameters

owner
string

Owner address.

Returns

Promise<
string[]
>
src/ocean/OceanAssets.ts#L336

transferOwnership

Method
Transfer ownership of an asset.

Parameters

did
string

Asset DID.

newOwner
string

Ethereum address of the new owner of the DID.

Returns

Promise<
TransactionReceipt
>
src/ocean/OceanAssets.ts#L346

consumerAssets

Method
Returns the assets of a consumer.

Parameters

consumer
string

Consumer address.

Returns

Promise<
string[]
>
src/ocean/OceanAssets.ts#L359

query

Method
Search over the assets using a query.

Parameters

query

Query to filter the assets.

Returns

Promise<>
src/ocean/OceanAssets.ts#L372

createAccessServiceAttributes

Method

Parameters

consumerAccount

price
string

datePublished
string

Returns

Promise<>
src/ocean/OceanAssets.ts#L395

OceanAgreements

Agreements submodule of Ocean Protocol.

conditions

Property
Agreements Conditions submodule.
src/ocean/OceanAgreements.ts#L39

prepare

Method
Creates a consumer signature for the specified asset service.

Parameters

did
string

Decentralized ID.

index
number

Service index.

consumer

Consumer account.

Returns

src/ocean/OceanAgreements.ts#L48

send

Method
Submit a service agreement to the publisher to create the agreement on-chain.

Parameters

did
string

Decentralized ID.

agreementId
string

index
number

Service index.

signature
string

consumer

Consumer account.

Returns

Promise<
void
>
src/ocean/OceanAgreements.ts#L81

create

Method
Create a service agreement on-chain. This should be called by the publisher of the asset. Consumer signature will be verified on-chain, but it is recommended to verify the signature in this method before submitting on-chain.

Parameters

did
string

Decentralized ID.

agreementId
string

Service agreement ID.

index
number

Service index.

signature
string

Service agreement signature.

consumer

Consumer account.

provider
string

ethereum address of service provider

from

account of party creating the agreement (usually the consumer).

Returns

Promise<
boolean
>
src/ocean/OceanAgreements.ts#L114

status

Method
Get the status of a service agreement.

Parameters

agreementId
string

Service agreement ID.

extended?
false

Returns a complete status with dependencies.

Returns

Promise<
>
src/ocean/OceanAgreements.ts#L145

OceanAgreementsConditions

Agreements Conditions submodule of Ocean Protocol.

lockReward

Method
Transfers tokens to the EscrowRewardCondition contract as an escrow payment. This is required before access can be given to the asset data.

Parameters

agreementId
string

Agreement ID.

amount

Asset amount.

from?

Account of sender.

Returns

Promise<
boolean
>
src/ocean/OceanAgreementsConditions.ts#L28

grantAccess

Method
Authorize the consumer defined in the agreement to access (consume) this asset.

Parameters

agreementId
string

Agreement ID.

did
string

Asset ID.

grantee
string

Consumer address.

from?

Account of sender.

Returns

Promise<
boolean
>
src/ocean/OceanAgreementsConditions.ts#L62

grantCompute

Method
Authorize the consumer defined in the agreement to compute on this asset.

Parameters

agreementId
string

Agreement ID.

did
string

Asset ID.

grantee
string

Consumer address.

from?

Account of sender.

Returns

Promise<
boolean
>
src/ocean/OceanAgreementsConditions.ts#L90

releaseReward

Method
If the AccessSecretStoreCondition already timed out, this function will do a refund by transferring the token amount to the original consumer.

Parameters

agreementId
string

Agreement ID.

amount
number

Asset amount.

did
string

Asset ID.

consumer
string

Consumer address.

publisher
string

Publisher address.

from?

Account of sender.

Returns

Promise<
boolean
>
src/ocean/OceanAgreementsConditions.ts#L124

OceanCompute

Compute submodule of Ocean Protocol.

order

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

Parameters

consumerAccount

The account of the consumer ordering the service.

datasetDid
string

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

provider?
string

src/ocean/OceanCompute.ts#L71

checkOutput

Method
Check the output object and add default properties if needed

Parameters

consumerAccount

The account of the consumer ordering the service.

output?

Output section used for publishing the result.

Returns

src/ocean/OceanCompute.ts#L100

start

Method
Start the execution of a compute job.

Parameters

consumerAccount

The account of the consumer ordering the service.

agreementId
string

The service agreement ID.

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.

Returns

Promise<>
src/ocean/OceanCompute.ts#L132

stop

Method
Ends a running compute job.

Parameters

consumerAccount

The account of the consumer ordering the service.

agreementId
string

The service agreement ID.

jobId
string

The ID of the compute job to be stopped

Returns

Promise<>
src/ocean/OceanCompute.ts#L160

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.

agreementId
string

The service agreement ID.

jobId
string

The ID of the compute job to be stopped

Returns

Promise<>
src/ocean/OceanCompute.ts#L184

restart

Method
Ends a running compute job and starts it again.

Parameters

consumerAccount

The account of the consumer ordering the service.

agreementId
string

The service agreement ID.

jobId
string

The ID of the compute job to be stopped

Returns

Promise<>
src/ocean/OceanCompute.ts#L208

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.

agreementId?
string

The service agreement ID.

jobId?
string

The ID of the compute job to be stopped

Returns

Promise<>
src/ocean/OceanCompute.ts#L225

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.

agreementId
string

The service agreement ID.

jobId
string

The ID of the compute job to be stopped.

Returns

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

createComputeServiceAttributes

Method

Parameters

consumerAccount

price
string

datePublished
string

Returns

src/ocean/OceanCompute.ts#L266

OceanSecretStore

SecretStore submodule of Ocean Protocol.

encrypt

Method
Encrypt the given text and store the encryption keys using the `did`. The encrypted text can be decrypted using the same keys identified by the `did`.

Parameters

did
string

Decentralized ID.

document
any

publisher

Publisher account.

Returns

Promise<
string
>
src/ocean/OceanSecretStore.ts#L33

decrypt

Method
Decrypt an encrypted text using the stored encryption keys associated with the `did`. Decryption requires that the account owner has access permissions for this `did`

Parameters

did
string

Decentralized ID.

content
string

Content to be encrypted.

consumer?

cONSUMER account.

secretStoreUrl?
string

Returns

Promise<
any
>
src/ocean/OceanSecretStore.ts#L62

OceanVersions

Versions submodule of Ocean Protocol.

Account

Account information.

getId

Method

Returns

string
src/ocean/Account.ts#L21

setId

Method

Parameters

id
any

Returns

void
src/ocean/Account.ts#L25

setPassword

Method
Set account password.

Parameters

password
string

Password for account.

Returns

void
src/ocean/Account.ts#L33

getPassword

Method
Returns account password.

Returns

string
src/ocean/Account.ts#L41

setToken

Method
Set account token.

Parameters

token
string

Token for account.

Returns

void
src/ocean/Account.ts#L49

getToken

Method
Returns account token.

Returns

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

isTokenStored

Method
Returns if account token is stored.

Returns

Promise<
boolean
>
src/ocean/Account.ts#L65

authenticate

Method
Authenticate the account.

Returns

Promise<
void
>
src/ocean/Account.ts#L72

getOceanBalance

Method
Balance of Ocean Token.

Returns

Promise<
number
>
src/ocean/Account.ts#L80

getEtherBalance

Method
Balance of Ether.

Returns

Promise<
number
>
src/ocean/Account.ts#L89

getBalance

Method
Balances of Ether and Ocean Token.

Returns

Promise<>
src/ocean/Account.ts#L101

requestTokens

Method
Request Ocean Tokens.

Parameters

amount

Tokens to be requested.

Returns

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

DID

Decentralized ID.

getDid

Method
Returns the DID.

Returns

string
src/ocean/DID.ts#L54

getId

Method
Returns the ID.

Returns

string
src/ocean/DID.ts#L62

DDO

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

@context

Property
string
src/ddo/DDO.ts#L33

id

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

created

Property
string
src/ddo/DDO.ts#L41

publicKey

Property
src/ddo/DDO.ts#L43

authentication

Property
src/ddo/DDO.ts#L45

service

Property
src/ddo/DDO.ts#L47

shortId

Method

Returns

string
src/ddo/DDO.ts#L58

findServiceById

Method
Finds a service of a DDO by index.

Parameters

index
number

Returns

src/ddo/DDO.ts#L67

findServiceByType

Method
Finds a service of a DDO by type.

Parameters

serviceType
T

Service type.

Returns

src/ddo/DDO.ts#L82

getChecksum

Method
Generate the checksum using the current content.

Returns

string
src/ddo/DDO.ts#L94

generateProof

Method
Generates proof using personal sing.

Parameters

ocean

Ocean instance.

publicKey
string

Public key to be used on personal sign.

password?
string

Password if it's required.

Returns

Promise<>
src/ddo/DDO.ts#L118

addProof

Method
Generates and adds a proof using personal sing on the DDO.

Parameters

ocean

Ocean instance.

publicKey
string

Public key to be used on personal sign.

password?
string

Password if it's required.

Returns

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

Aquarius

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

getVersionInfo

Method

Returns

Promise<
any
>
src/aquarius/Aquarius.ts#L48

getAccessUrl

Method

Parameters

accessToken
any

payload
any

Returns

Promise<
string
>
src/aquarius/Aquarius.ts#L52

queryMetadata

Method
Search over the DDOs using a query.

Parameters

query

Query to filter the DDOs.

Returns

Promise<>
src/aquarius/Aquarius.ts#L82

queryMetadataByText

Method
Search over the DDOs using a query.

Parameters

query

Query to filter the DDOs.

Returns

Promise<>
src/aquarius/Aquarius.ts#L112

storeDDO

Method
Stores a DDO in Aquarius.

Parameters

ddo

DDO to be stored.

Returns

Promise<>
src/aquarius/Aquarius.ts#L151

retrieveDDO

Method
Retrieves a DDO by DID.

Parameters

did

DID of the asset.

metadataServiceEndpoint?
string

Returns

Promise<>
src/aquarius/Aquarius.ts#L183

retrieveDDOByUrl

Method

Parameters

metadataServiceEndpoint?
string

Returns

Promise<>
src/aquarius/Aquarius.ts#L214

getServiceEndpoint

Method

Parameters

did

Returns

string
src/aquarius/Aquarius.ts#L218

Brizo

Provides a interface with Brizo. Brizo is the technical component executed by the Publishers allowing to them to provide extended data services.

getVersionInfo

Method

Returns

Promise<
any
>
src/brizo/Brizo.ts#L25

getPurchaseEndpoint

Method

Returns

string
src/brizo/Brizo.ts#L29

getConsumeEndpoint

Method

Returns

string
src/brizo/Brizo.ts#L33

getEncryptEndpoint

Method

Returns

string
src/brizo/Brizo.ts#L37

getComputeEndpoint

Method

Returns

string
src/brizo/Brizo.ts#L41

getEndpointFromAgreement

Method

Parameters

agreementId
string

Returns

Promise<
string
>
src/brizo/Brizo.ts#L45

initializeServiceAgreement

Method

Parameters

did
string

serviceAgreementId
string

serviceIndex
number

signature
string

consumerAddress
string

Returns

Promise<
any
>
src/brizo/Brizo.ts#L57

consumeService

Method

Parameters

agreementId
string

serviceEndpoint
string

account

files

destination
string

index
number

Returns

Promise<
string
>
src/brizo/Brizo.ts#L83

compute

Method

Parameters

method
string

serviceAgreementId
string

consumerAccount

algorithmDid?
string

algorithmMeta?

jobId?
string

output?

Returns

Promise<
>
src/brizo/Brizo.ts#L113

createSignature

Method

Parameters

account

agreementId
string

Returns

Promise<
string
>
src/brizo/Brizo.ts#L189

encrypt

Method

Parameters

did
string

signature
string

document
any

publisher
string

Returns

Promise<
string
>
src/brizo/Brizo.ts#L200

Keeper

Interface with Ocean Keeper contracts. Ocean Keeper implementation where we put the following modules together: - TCRs: users create challenges and resolve them through voting to maintain registries. - Ocean Tokens: the intrinsic tokens circulated inside Ocean network, which is used in the voting of TCRs. - Marketplace: the core marketplace where people can transact with each other with Ocean tokens.

connected

Property
Is connected to the correct network or not.
boolean
src/keeper/Keeper.ts#L123

token

Property
Ocean Token smart contract instance.
src/keeper/Keeper.ts#L129

dispenser

Property
Ocean Market smart contract instance.
src/keeper/Keeper.ts#L135

didRegistry

Property
DID registry smart contract instance.
src/keeper/Keeper.ts#L141

templateStoreManager

Property
Template store manager smart contract instance.
src/keeper/Keeper.ts#L147

agreementStoreManager

Property
Template store manager smart contract instance.
src/keeper/Keeper.ts#L153

conditionStoreManager

Property
Template store manager smart contract instance.
src/keeper/Keeper.ts#L159

conditions

Property
Conditions instances.
src/keeper/Keeper.ts#L164

templates

Property
Templates instances.
src/keeper/Keeper.ts#L174

utils

Property
Helpers for contracts.
src/keeper/Keeper.ts#L182

getConditionByAddress

Method
Returns a condition by address.

Parameters

address
string

Address of deployed condition.

Returns

src/keeper/Keeper.ts#L193

getTemplateByName

Method
Returns a template by name.

Parameters

name
string

Template name.

src/keeper/Keeper.ts#L204

getTemplateById

Method
Returns a template by address.

Parameters

templateId
string

Template id (hex representation of bytes32).

src/keeper/Keeper.ts#L215

getNetworkId

Method
Returns network id.

Returns

Promise<
number
>
src/keeper/Keeper.ts#L225

getNetworkName

Method
Returns the network by name.

Returns

Promise<
string
>
src/keeper/Keeper.ts#L233

getAllInstances

Method

Returns

src/keeper/Keeper.ts#L240

ContractHandler

get

Method

Parameters

what
string

optional
boolean

Returns

Promise<
Contract
>
src/keeper/ContractHandler.ts#L32

EventHandler

subscribe

Method

Parameters

callback

Returns

src/keeper/EventHandler.ts#L26

unsubscribe

Method

Parameters

callback

Returns

void
src/keeper/EventHandler.ts#L35

getEvent

Method

Parameters

contract

eventName
string

filter

src/keeper/EventHandler.ts#L44

Web3Provider

Config

aquariusUri

Property
Aquarius URL.
string
src/models/Config.ts#L9

brizoUri

Property
Brizo URL.
string
src/models/Config.ts#L15

brizoAddress

Property
Address of Brizo.
string
src/models/Config.ts#L21

nodeUri

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

web3Provider

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

secretStoreUri

Property
Secret Store URL.
string
src/models/Config.ts#L39

verbose

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

authMessage

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

authTokenExpiration

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

parityUri

Property
string
src/models/Config.ts#L60

threshold

Property
number
src/models/Config.ts#L62

Balance

eth

Property
number
src/models/Balance.ts#L2

ocn

Property
number
src/models/Balance.ts#L4

OceanUtils

Utils internal submodule of Ocean Protocol.

agreements

Property
Agreement utils.
src/ocean/utils/OceanUtils.ts#L36

services

Property
Service utils.
src/ocean/utils/OceanUtils.ts#L42

signature

Property
Signature utils.
src/ocean/utils/OceanUtils.ts#L48

ServiceAgreement

signServiceAgreement

Method

Parameters

ddo

index
number

serviceAgreementId
string

agreementConditionsIds
string[]

consumer

Returns

Promise<
string
>
src/ocean/utils/ServiceAgreement.ts#L19

createHashSignature

Method

Parameters

templateId
string

serviceAgreementId
string

valueHashes
string[]

timelockValues
number[]

timeoutValues
number[]

consumer

Returns

Promise<
string
>
src/ocean/utils/ServiceAgreement.ts#L51

hashServiceAgreement

Method

Parameters

serviceAgreementTemplateId
string

serviceAgreementId
string

valueHashes
string[]

timelocks
number[]

timeouts
number[]

Returns

string
src/ocean/utils/ServiceAgreement.ts#L76

WebServiceConnector

Provides a common interface to web services.

post

Method

Parameters

url
string

payload
BodyInit

Returns

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

get

Method

Parameters

url
string

Returns

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

put

Method

Parameters

url
string

payload
BodyInit

Returns

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

delete

Method

Parameters

url
string

Returns

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

downloadFile

Method

Parameters

url
string

destination?
string

index?
number

Returns

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

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