1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
ocean.js/docs/overview.md
Jamie Hewitt 7f05b8fdb5
Issue 668/documentation improvements (#669)
* Creating list of prerequisites

* adding installation command in testing flow

* creaitng learn more section in readme + new MD files

* creating instructions for wallets

* adding addition links to readme

* saving placeholders

* WIP content added for paramenters.md readme

* adding WIP content for services.md readme

* adding content to overview readme

* updating dependancies in simple flow quickstart

* updating simpleflow quickstart code & dependancies

* updates to marketplace quickstart code snippet

* fixing issues with creating datatoken in simple flow quickstart

* updating the simplefloe quickstartt steps

* adding steps for getting set up

* Adding template code to quickstart

* Quickstart: minting 100 tokens code added

* Quickstart: transfering tokens from ALice to Bob

* Quickstart: adding steps for publishing a dataset

* Quickstart: adding steps for downloading a dataset

* Marketplace Quickstart: adding initial steps

* Marketplace Quickstart: adding steps for publishing dataset

* Marketplace Quickstart: allowing marketplace to send tokens

* Marketplace Quickstart: adding marketplace address

* Marketplace Quickstart: marketplace withdraws datatoken allowance

* Overiew: adding all asset functions

* Overiew readme: adding all pool functions

* Overiew readme: adding all exchange functions

* Overiew readme: adding all compute functions

* Marketplace quickstart: Bob acquires tokens

* Marketplace quickstart: Bob downloads data + extensions

* minor fixes

* Readme: adding links to discord and creating github issues

* adding link to marketplace flow + fixing spelling mistake

* adding link to marketplace flow + fixing spelling mistake

* fixing dependancy issue

* adding beginners guide

* code formatting

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-13 17:10:16 +02:00

11 KiB

Overview

Here is an overview of all ot the main functions and submodules:

Ocean instance

Create/get datatoken, get dtfactory, user orders (history)

import { Ocean } from '@oceanprotocol/lib'
const ocean = await Ocean.getInstance(config)

Then use the following submodules...

Assets

Publish, get, list, search, order, consume/download

ocean.asset.getInstance(config: InstantiableConfig): Promise<Assets>;
ocean.asset.create(metadata: Metadata, publisher: Account, services?: Service[], dtAddress?: string, cap?: string, name?: string, symbol?: string, providerUri?: string): SubscribablePromise<CreateProgressStep, DDO>;
ocean.asset.ownerAssets(owner: string): Promise<QueryResult>;
ocean.asset.resolve(did: string): Promise<DDO>;
ocean.asset.resolveByDTAddress(dtAddress: string, offset?: number, page?: number, sort?: number): Promise<DDO[]>;
ocean.asset.editMetadata(ddo: DDO, newMetadata: EditableMetadata): Promise<DDO>;
ocean.asset.updateMetadata(ddo: DDO, consumerAccount: string): Promise<TransactionReceipt>;
ocean.asset.editServiceTimeout(ddo: DDO, serviceIndex: number, timeout: number): Promise<DDO>;
ocean.asset.creator(did: string): Promise<string>;
ocean.asset.query(query: SearchQuery): Promise<QueryResult>;
ocean.asset.search(text: string): Promise<QueryResult>;
ocean.asset.getServiceByType(did: string, serviceType: string): Promise<Service>;
ocean.asset.getServiceByIndex(did: string, serviceIndex: number): Promise<Service>;
ocean.asset.createAccessServiceAttributes(creator: Account, cost: string, datePublished: string, timeout?: number, providerUri?: string): Promise<ServiceAccess>;
ocean.asset.initialize(did: string, serviceType: string, consumerAddress: string, serviceIndex: number, serviceEndpoint: string): Promise<any>;
ocean.asset.order(did: string, serviceType: string, payerAddress: string, serviceIndex?: number, mpAddress?: string, consumerAddress?: string, searchPreviousOrders?: boolean): Promise<string>;
ocean.asset.download(did: string, txId: string, tokenAddress: string, consumerAccount: Account, destination: string): Promise<string | true>;
ocean.asset.simpleDownload(dtAddress: string, serviceEndpoint: string, txId: string, account: string): Promise<string>;
ocean.asset.getOrderHistory(account: Account, serviceType?: string, fromBlock?: number): Promise<Order[]>;

Datatoken Pool

Create, add/remove liquidity, check liquidity, price, buy datatokens

ocean.pool.
ocean.pool.createDTPool(account: string, token: string, amount: string, weight: string, fee: string): Promise<string>;
ocean.pool.getDTAddress(poolAddress: string): Promise<string>;
ocean.pool.getOceanReserve(poolAddress: string): Promise<string>;
ocean.pool.getDTReserve(poolAddress: string): Promise<string>;
ocean.pool.getMaxBuyQuantity(poolAddress: string, tokenAddress: string): Promise<string>;
ocean.pool.getOceanMaxBuyQuantity(poolAddress: string): Promise<string>;
ocean.pool.getDTMaxBuyQuantity(poolAddress: string): Promise<string>;
ocean.pool.calcInGivenOut(poolAddress: string, tokenInAddress: string, tokenOutAddress: string, tokenOutAmount: string): Promise<string>;
ocean.pool.calcOutGivenIn(poolAddress: string, tokenInAddress: string, tokenOutAddress: string, tokenInAmount: string): Promise<string>;
ocean.pool.calcPoolOutGivenSingleIn(poolAddress: string, tokenInAddress: string, tokenInAmount: string): Promise<string>;
ocean.pool.calcSingleInGivenPoolOut(poolAddress: string, tokenInAddress: string, poolShares: string): Promise<string>;
ocean.pool.calcSingleOutGivenPoolIn(poolAddress: string, tokenOutAddress: string, poolShares: string): Promise<string>;
ocean.pool.calcPoolInGivenSingleOut(poolAddress: string, tokenOutAddress: string, tokenOutAmount: string): Promise<string>;
ocean.pool.getPoolSharesRequiredToRemoveDT(poolAddress: string, dtAmount: string): Promise<string>;
ocean.pool.getDTRemovedforPoolShares(poolAddress: string, poolShares: string): Promise<string>;
ocean.pool.getPoolSharesRequiredToRemoveOcean(poolAddress: string, oceanAmount: string): Promise<string>;
ocean.pool.getOceanRemovedforPoolShares(poolAddress: string, poolShares: string): Promise<string>;
ocean.pool.getTokensRemovedforPoolShares(poolAddress: string, poolShares: string): Promise<TokensReceived>;
ocean.pool.getDTMaxAddLiquidity(poolAddress: string): Promise<string>;
ocean.pool.getOceanMaxAddLiquidity(poolAddress: string): Promise<string>;
ocean.pool.getMaxAddLiquidity(poolAddress: string, tokenAddress: string): Promise<string>;
ocean.pool.getMaxRemoveLiquidity(poolAddress: string, tokenAddress: string): Promise<string>;
ocean.pool.getDTMaxRemoveLiquidity(poolAddress: string): Promise<string>;
ocean.pool.getOceanMaxRemoveLiquidity(poolAddress: string): Promise<string>;
ocean.pool.buyDT(account: string, poolAddress: string, dtAmountWanted: string, maxOceanAmount: string, maxPrice?: string): Promise<TransactionReceipt>;
ocean.pool.sellDT(account: string, poolAddress: string, dtAmount: string, oceanAmountWanted: string, maxPrice?: string): Promise<TransactionReceipt>;
ocean.pool.addDTLiquidity(account: string, poolAddress: string, amount: string): Promise<TransactionReceipt>;
ocean.pool.removeDTLiquidity(account: string, poolAddress: string, amount: string, maximumPoolShares: string): Promise<TransactionReceipt>;
ocean.pool.addOceanLiquidity(account: string, poolAddress: string, amount: string): Promise<TransactionReceipt>;
ocean.pool.removeOceanLiquidity(account: string, poolAddress: string, amount: string, maximumPoolShares: string): Promise<TransactionReceipt>;
ocean.pool.removePoolLiquidity(account: string, poolAddress: string, poolShares: string, minDT?: string, minOcean?: string): Promise<TransactionReceipt>;
ocean.pool.getDTPrice(poolAddress: string): Promise<string>;
ocean.pool.searchPoolforDT(dtAddress: string): Promise<string[]>;
ocean.pool.getOceanNeeded(poolAddress: string, dtRequired: string): Promise<string>;
ocean.pool.getOceanReceived(poolAddress: string, dtSold: string): Promise<string>;
ocean.pool.getDTNeeded(poolAddress: string, OceanRequired: string): Promise<string>;
ocean.pool.getPoolsbyCreator(account?: string): Promise<PoolDetails[]>;
ocean.pool.getPoolDetails(poolAddress: string): Promise<PoolDetails>;
ocean.pool.getPoolLogs(poolAddress: string, account?: string): Promise<PoolTransaction[]>;
ocean.pool.getAllPoolLogs(account: string): Promise<PoolTransaction[]>;

Fixed rate exchange

Create, price, buy datatokens

ocean.exchange.create(dataToken: string, rate: string, address: string): Promise<string>;
ocean.exchange.generateExchangeId(dataToken: string, owner: string): Promise<string>;
ocean.exchange.buyDT(exchangeId: string, dataTokenAmount: string, address: string): Promise<TransactionReceipt>;
ocean.exchange.getNumberOfExchanges(): Promise<number>;
ocean.exchange.setRate(exchangeId: string, newRate: number, address: string): Promise<TransactionReceipt>;
ocean.exchange.activate(exchangeId: string, address: string): Promise<TransactionReceipt>;
ocean.exchange.deactivate(exchangeId: string, address: string): Promise<TransactionReceipt>;
ocean.exchange.getRate(exchangeId: string): Promise<string>;
ocean.exchange.getSupply(exchangeId: string): Promise<string>;
ocean.exchange.getOceanNeeded(exchangeId: string, dataTokenAmount: string): Promise<string>;
ocean.exchange.getExchange(exchangeId: string): Promise<FixedPriceExchange>;
ocean.exchange.getExchanges(): Promise<string[]>;
ocean.exchange.isActive(exchangeId: string): Promise<boolean>;
ocean.exchange.CalcInGivenOut(exchangeId: string, dataTokenAmount: string): Promise<string>;
ocean.exchange.searchforDT(dataTokenAddress: string, minSupply: string): Promise<FixedPriceExchange[]>;
ocean.exchange.getExchangesbyCreator(account?: string): Promise<FixedPriceExchange[]>;
ocean.exchange.getExchangeSwaps(exchangeId: string, account?: string): Promise<FixedPriceSwap[]>;
ocean.exchange.getAllExchangesSwaps(account: string): Promise<FixedPriceSwap[]>;

Compute-to-data

consume/start, stop, results, status, define-service

ocean.compute.start(did: string, txId: string, tokenAddress: string, consumerAccount: Account, algorithmDid?: string, algorithmMeta?: MetadataAlgorithm, output?: Output, serviceIndex?: string, serviceType?: string, algorithmTransferTxId?: string, algorithmDataToken?: string): Promise<ComputeJob>;
ocean.compute.stop(consumerAccount: Account, did: string, jobId: string): Promise<ComputeJob>;
ocean.compute.delete(consumerAccount: Account, did: string, jobId: string): Promise<ComputeJob>;
ocean.compute.status(consumerAccount: Account, did?: string, jobId?: string): Promise<ComputeJob[]>;
ocean.compute.result(consumerAccount: Account, did: string, jobId: string): Promise<ComputeJob>;
ocean.compute.createServerAttributes(serverId: string, serverType: string, cost: string, cpu: string, gpu: string, memory: string, disk: string, maxExecutionTime: number): Server;
ocean.compute.createContainerAttributes(image: string, tag: string, checksum: string): Container;
ocean.compute.createClusterAttributes(type: string, url: string): Cluster;
ocean.compute.createProviderAttributes(type: string, description: string, cluster: Cluster, containers: Container[], servers: Server[]): {
        type: string;
        description: string;
        environment: {
            cluster: Cluster;
            supportedServers: Server[];
            supportedContainers: Container[];
        };
    };
ocean.compute.createComputeService(consumerAccount: Account, cost: string, datePublished: string, providerAttributes: any, computePrivacy?: ServiceComputePrivacy, timeout?: number, providerUri?: string): ServiceCompute;
ocean.compute.order(consumerAccount: string, datasetDid: string, serviceIndex: number, algorithmDid?: string, algorithmMeta?: MetadataAlgorithm, mpAddress?: string): SubscribablePromise<OrderProgressStep, string>;