Squid-js 1.0.0-beta.6

JavaScript client library for Ocean Protocol

Ocean

Main interface for Ocean Protocol.

keeper

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

brizo

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

aquarius

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

accounts

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

auth

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

assets

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

agreements

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

secretStore

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

tokens

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

versions

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

utils

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

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 a 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#L49

create

Method
Creates a new DDO.

Parameters

metadata

DDO metadata.

publisher

Publisher account.

services

src/ocean/OceanAssets.ts#L62

consume

Method

Parameters

agreementId
string

did
string

serviceIndex
number

consumerAccount

resultPath
string

index?
number

useSecretStore?
boolean

Returns

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

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.

index
number

Service index.

consumer

Consumer account.

src/ocean/OceanAssets.ts#L288

owner

Method
Returns the owner of a asset.

Parameters

did
string

Decentralized ID.

Returns

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

ownerAssets

Method
Returns the assets of a owner.

Parameters

owner
string

Owner address.

Returns

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

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#L403

consumerAssets

Method
Returns the assets of a consumer.

Parameters

consumer
string

Consumer address.

Returns

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

query

Method
Search over the assets using a query.

Parameters

query

Query to filter the assets.

Returns

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

OceanAgreements

Agreements submodule of Ocean Protocol.

conditions

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

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#L47

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#L80

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.

publisher

Publisher account.

Returns

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

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#L138

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

grantServiceExecution

Method
Authorize the consumer defined in the agreement to execute a remote service associated with 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

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 a interface with Aquarius. Aquarius provides an off-chain database store for metadata about data assets.

getVersionInfo

Method

Returns

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

getAccessUrl

Method

Parameters

accessToken
any

payload
any

Returns

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

queryMetadata

Method
Search over the DDOs using a query.

Parameters

query

Query to filter the DDOs.

Returns

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

queryMetadataByText

Method
Search over the DDOs using a query.

Parameters

query

Query to filter the DDOs.

Returns

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

storeDDO

Method
Stores a DDO in Aquarius.

Parameters

ddo

DDO to be stored.

Returns

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

retrieveDDO

Method
Retrieves a DDO by DID.

Parameters

did

DID of the asset.

metadataServiceEndpoint?
string

Returns

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

retrieveDDOByUrl

Method

Parameters

metadataServiceEndpoint?
string

Returns

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

getServiceEndpoint

Method

Parameters

did

Returns

string
src/aquarius/Aquarius.ts#L206

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#L22

getPurchaseEndpoint

Method

Returns

string
src/brizo/Brizo.ts#L26

getConsumeEndpoint

Method

Returns

string
src/brizo/Brizo.ts#L30

getEncryptEndpoint

Method

Returns

string
src/brizo/Brizo.ts#L34

getComputeEndpoint

Method

Parameters

pubKey
string

serviceIndex
number

_notUsed
string

container
string

Returns

string
src/brizo/Brizo.ts#L38

initializeServiceAgreement

Method

Parameters

did
string

serviceAgreementId
string

serviceIndex
number

signature
string

consumerAddress
string

Returns

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

consumeService

Method

Parameters

agreementId
string

serviceEndpoint
string

account

files

destination
string

index
number

Returns

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

encrypt

Method

Parameters

did
string

signature
string

document
any

publisher
string

Returns

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

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#L122

token

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

dispenser

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

didRegistry

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

templateStoreManager

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

agreementStoreManager

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

conditionStoreManager

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

conditions

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

templates

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

utils

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

getConditionByAddress

Method
Returns a condition by address.

Parameters

address
string

Address of deployed condition.

Returns

src/keeper/Keeper.ts#L192

getTemplateByName

Method
Returns a template by name.

Parameters

name
string

Template name.

src/keeper/Keeper.ts#L203

getTemplateByAddress

Method
Returns a template by address.

Parameters

address
string

Template address.

src/keeper/Keeper.ts#L214

getNetworkId

Method
Returns network id.

Returns

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

getNetworkName

Method
Returns the network by name.

Returns

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

getAllInstances

Method

Returns

src/keeper/Keeper.ts#L263

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#L30

signature

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

ServiceAgreement

signServiceAgreement

Method

Parameters

ddo

index
number

serviceAgreementId
string

agreementConditionsIds
string[]

consumer

Returns

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

createHashSignature

Method

Parameters

templateId
string

serviceAgreementId
string

valueHashes
string[]

timelockValues
number[]

timeoutValues
number[]

consumer

Returns

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

hashServiceAgreement

Method

Parameters

serviceAgreementTemplateId
string

serviceAgreementId
string

valueHashes
string[]

timelocks
number[]

timeouts
number[]

Returns

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

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

downloadFile

Method

Parameters

url
string

destination?
string

index?
number

Returns

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

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