Last updated
Last updated
/ / / EscrowClient
.EscrowClient
This client enables to perform actions on Escrow contracts and obtain information from both the contracts and subgraph.
Internally, the SDK will use one network or another according to the network ID of the runner
. To use this client, it is recommended to initialize it using the static build
method.
A Signer
or a Provider
should be passed depending on the use case of this module:
Signer: when the user wants to use this model in order to send transactions caling the contract functions.
Provider: when the user wants to use this model in order to get information from the contracts or subgraph.
Using private key(backend)
Using Wagmi(frontend)
↳ EscrowClient
EscrowClient constructor
Parameters
Returns
Overrides
Defined in
• Private
escrowFactoryContract: EscrowFactory
Defined in
• networkData: NetworkData
Inherited from
Defined in
• Protected
runner: ContractRunner
Inherited from
Defined in
▸ abort(escrowAddress
, txOptions?
): Promise
<void
>
This function cancels the specified escrow, sends the balance to the canceler and selfdestructs the escrow contract.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Only Job Launcher or trusted handler can call it.
Defined in
▸ addTrustedHandlers(escrowAddress
, trustedHandlers
, txOptions?
): Promise
<void
>
This function sets the status of an escrow to completed.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Only Job Launcher or trusted handler can call it.
Defined in
▸ bulkPayOut(escrowAddress
, recipients
, amounts
, finalResultsUrl
, finalResultsHash
, txOptions?
): Promise
<void
>
This function pays out the amounts specified to the workers and sets the URL of the final results file.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Only Reputation Oracle or a trusted handler can call it.
Defined in
▸ cancel(escrowAddress
, txOptions?
): Promise
<EscrowCancel
>
This function cancels the specified escrow and sends the balance to the canceler.
Parameters
Returns
Promise
<EscrowCancel
>
Returns the escrow cancellation data including transaction hash and refunded amount. Throws error if any.
Code example
Only Job Launcher or a trusted handler can call it.
Defined in
▸ complete(escrowAddress
, txOptions?
): Promise
<void
>
This function sets the status of an escrow to completed.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Only Recording Oracle or a trusted handler can call it.
Defined in
▸ createAndSetupEscrow(tokenAddress
, trustedHandlers
, jobRequesterId
, escrowConfig
): Promise
<string
>
This function creates and sets up an escrow.
Parameters
Returns
Promise
<string
>
Returns the address of the escrow created.
Code example
Defined in
▸ createEscrow(tokenAddress
, trustedHandlers
, jobRequesterId
, txOptions?
): Promise
<string
>
This function creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
Parameters
Returns
Promise
<string
>
Return the address of the escrow created.
Code example
Need to have available stake.
Defined in
▸ fund(escrowAddress
, amount
, txOptions?
): Promise
<void
>
This function adds funds of the chosen token to the escrow.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Defined in
▸ getBalance(escrowAddress
): Promise
<bigint
>
This function returns the balance for a specified escrow address.
Parameters
Returns
Promise
<bigint
>
Balance of the escrow in the token used to fund it.
Code example
Defined in
▸ getEscrowContract(escrowAddress
): Escrow
Connects to the escrow contract
Parameters
Returns
Escrow
Defined in
▸ getExchangeOracleAddress(escrowAddress
): Promise
<string
>
This function returns the exchange oracle address for a given escrow.
Parameters
Returns
Promise
<string
>
Address of the Exchange Oracle.
Code example
Defined in
▸ getFactoryAddress(escrowAddress
): Promise
<string
>
This function returns the escrow factory address for a given escrow.
Parameters
Returns
Promise
<string
>
Address of the escrow factory.
Code example
Defined in
▸ getIntermediateResultsUrl(escrowAddress
): Promise
<string
>
This function returns the intermediate results file URL.
Parameters
Returns
Promise
<string
>
Url of the file that store results from Recording Oracle.
Code example
Defined in
▸ getJobLauncherAddress(escrowAddress
): Promise
<string
>
This function returns the job launcher address for a given escrow.
Parameters
Returns
Promise
<string
>
Address of the Job Launcher.
Code example
Defined in
▸ getManifestHash(escrowAddress
): Promise
<string
>
This function returns the manifest file hash.
Parameters
Returns
Promise
<string
>
Hash of the manifest file content.
Code example
Defined in
▸ getManifestUrl(escrowAddress
): Promise
<string
>
This function returns the manifest file URL.
Parameters
Returns
Promise
<string
>
Url of the manifest.
Code example
Defined in
▸ getRecordingOracleAddress(escrowAddress
): Promise
<string
>
This function returns the recording oracle address for a given escrow.
Parameters
Returns
Promise
<string
>
Address of the Recording Oracle.
Code example
Defined in
▸ getReputationOracleAddress(escrowAddress
): Promise
<string
>
This function returns the reputation oracle address for a given escrow.
Parameters
Returns
Promise
<string
>
Address of the Reputation Oracle.
Code example
Defined in
▸ getResultsUrl(escrowAddress
): Promise
<string
>
This function returns the results file URL.
Parameters
Returns
Promise
<string
>
Results file url.
Code example
Defined in
▸ getStatus(escrowAddress
): Promise
<EscrowStatus
>
This function returns the current status of the escrow.
Parameters
Returns
Promise
<EscrowStatus
>
Current status of the escrow.
Code example
Defined in
▸ getTokenAddress(escrowAddress
): Promise
<string
>
This function returns the token address used for funding the escrow.
Parameters
Returns
Promise
<string
>
Address of the token used to fund the escrow.
Code example
Defined in
▸ setup(escrowAddress
, escrowConfig
, txOptions?
): Promise
<void
>
This function sets up the parameters of the escrow.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Only Job Launcher or a trusted handler can call it.
Defined in
▸ storeResults(escrowAddress
, url
, hash
, txOptions?
): Promise
<void
>
This function stores the results url and hash.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Only Recording Oracle or a trusted handler can call it.
Defined in
Creates an instance of EscrowClient from a Runner.
Parameters
Returns
An instance of EscrowClient
Throws
Thrown if the provider does not exist for the provided Signer
Throws
Thrown if the network's chainId is not supported
Defined in
• new EscrowClient(runner
, networkData
):
.
.
.
▸ build(runner
): Promise
<>
Promise
<>
runner
ContractRunner
The Runner object to interact with the Ethereum network
networkData
NetworkData
-
escrowAddress
string
Address of the escrow.
txOptions?
Overrides
Additional transaction parameters (optional, defaults to an empty object).
escrowAddress
string
Address of the escrow.
trustedHandlers
string
[]
Array of addresses of trusted handlers to add.
txOptions?
Overrides
Additional transaction parameters (optional, defaults to an empty object).
escrowAddress
string
Escrow address to payout.
recipients
string
[]
Array of recipient addresses.
amounts
bigint
[]
Array of amounts the recipients will receive.
finalResultsUrl
string
Final results file url.
finalResultsHash
string
Final results file hash.
txOptions?
Overrides
Additional transaction parameters (optional, defaults to an empty object).
escrowAddress
string
Address of the escrow to cancel.
txOptions?
Overrides
Additional transaction parameters (optional, defaults to an empty object).
escrowAddress
string
Address of the escrow.
txOptions?
Overrides
Additional transaction parameters (optional, defaults to an empty object).
tokenAddress
string
Token address to use for pay outs.
trustedHandlers
string
[]
Array of addresses that can perform actions on the contract.
jobRequesterId
string
Job Requester Id
escrowConfig
IEscrowConfig
Configuration object with escrow settings.
tokenAddress
string
Token address to use for pay outs.
trustedHandlers
string
[]
Array of addresses that can perform actions on the contract.
jobRequesterId
string
Job Requester Id
txOptions?
Overrides
Additional transaction parameters (optional, defaults to an empty object).
escrowAddress
string
Address of the escrow to fund.
amount
bigint
Amount to be added as funds.
txOptions?
Overrides
Additional transaction parameters (optional, defaults to an empty object).
escrowAddress
string
Address of the escrow.
escrowAddress
string
Escrow address to connect to
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow.
escrowAddress
string
Address of the escrow to set up.
escrowConfig
IEscrowConfig
Escrow configuration parameters.
txOptions?
Overrides
Additional transaction parameters (optional, defaults to an empty object).
escrowAddress
string
Address of the escrow.
url
string
Results file url.
hash
string
Results file hash.
txOptions?
Overrides
Additional transaction parameters (optional, defaults to an empty object).
runner
ContractRunner
The Runner object to interact with the Ethereum network