EscrowUtils

@human-protocol/sdkDocs


@human-protocol/sdk / escrow / EscrowUtils

Class: EscrowUtils

Introduction

Utility class for escrow-related operations.

Installation

npm

npm install @human-protocol/sdk

yarn

yarn install @human-protocol/sdk

Code example

Signer

Using private key(backend)

import { ChainId, EscrowUtils } from '@human-protocol/sdk';

const escrowAddresses = new EscrowUtils.getEscrows({
  networks: [ChainId.POLYGON_AMOY]
});

Constructors

new EscrowUtils()

new EscrowUtils(): EscrowUtils

Returns

EscrowUtils

Methods

getEscrow()

static getEscrow(chainId, escrowAddress): Promise<EscrowData>

This function returns the escrow data for a given address.

This uses Subgraph

Input parameters

enum ChainId {
  ALL = -1,
  MAINNET = 1,
  RINKEBY = 4,
  GOERLI = 5,
  BSC_MAINNET = 56,
  BSC_TESTNET = 97,
  POLYGON = 137,
  POLYGON_MUMBAI = 80001,
  POLYGON_AMOY = 80002,
  MOONBEAM = 1284,
  MOONBASE_ALPHA = 1287,
  AVALANCHE = 43114,
  AVALANCHE_TESTNET = 43113,
  CELO = 42220,
  CELO_ALFAJORES = 44787,
  LOCALHOST = 1338,
}
type EscrowData = {
  id: string;
  address: string;
  amountPaid: string;
  balance: string;
  count: string;
  jobRequesterId: string;
  factoryAddress: string;
  finalResultsUrl?: string;
  intermediateResultsUrl?: string;
  launcher: string;
  manifestHash?: string;
  manifestUrl?: string;
  recordingOracle?: string;
  recordingOracleFee?: string;
  reputationOracle?: string;
  reputationOracleFee?: string;
  exchangeOracle?: string;
  exchangeOracleFee?: string;
  status: EscrowStatus;
  token: string;
  totalFundedAmount: string;
  createdAt: string;
};

Parameters

chainId: ChainId

Network in which the escrow has been deployed

escrowAddress: string

Address of the escrow

Returns

Promise<EscrowData>

Escrow data

Code example

import { ChainId, EscrowUtils } from '@human-protocol/sdk';

const escrowData = new EscrowUtils.getEscrow(ChainId.POLYGON_AMOY, "0x1234567890123456789012345678901234567890");

Source

escrow.ts:1633


getEscrows()

static getEscrows(filter): Promise<EscrowData[]>

This function returns an array of escrows based on the specified filter parameters.

Input parameters

interface IEscrowsFilter {
  networks: ChainId[];
  launcher?: string;
  reputationOracle?: string;
  recordingOracle?: string;
  exchangeOracle?: string;
  jobRequesterId?: string;
  status?: EscrowStatus;
  from?: Date;
  to?: Date;
}
enum ChainId {
  ALL = -1,
  MAINNET = 1,
  RINKEBY = 4,
  GOERLI = 5,
  BSC_MAINNET = 56,
  BSC_TESTNET = 97,
  POLYGON = 137,
  POLYGON_MUMBAI = 80001,
  POLYGON_AMOY=80002,
  MOONBEAM = 1284,
  MOONBASE_ALPHA = 1287,
  AVALANCHE = 43114,
  AVALANCHE_TESTNET = 43113,
  CELO = 42220,
  CELO_ALFAJORES = 44787,
   = 1273227453,
  LOCALHOST = 1338,
}
enum EscrowStatus {
  Launched,
  Pending,
  Partial,
  Paid,
  Complete,
  Cancelled,
}
type EscrowData = {
  id: string;
  address: string;
  amountPaid: string;
  balance: string;
  count: string;
  jobRequesterId: string;
  factoryAddress: string;
  finalResultsUrl?: string;
  intermediateResultsUrl?: string;
  launcher: string;
  manifestHash?: string;
  manifestUrl?: string;
  recordingOracle?: string;
  recordingOracleFee?: string;
  reputationOracle?: string;
  reputationOracleFee?: string;
  exchangeOracle?: string;
  exchangeOracleFee?: string;
  status: EscrowStatus;
  token: string;
  totalFundedAmount: string;
  createdAt: string;
};

Parameters

filter: IEscrowsFilter

Filter parameters.

Returns

Promise<EscrowData[]>

List of escrows that match the filter.

Code example

import { ChainId, EscrowUtils, EscrowStatus } from '@human-protocol/sdk';

const filters: IEscrowsFilter = {
  status: EscrowStatus.Pending,
  from: new Date(2023, 4, 8),
  to: new Date(2023, 5, 8),
  networks: [ChainId.POLYGON_AMOY]
};
const escrowDatas = await EscrowUtils.getEscrows(filters);

Source

escrow.ts:1505

Last updated