Escrow SDK
A class that lets you create and manage Kleros Escrow transactions.
This class lets you create and manage Kleros Escrow transactions. Use this Kleros Escrow SDK to easily integrate on-chain escrow features on your platform.
npm i @kleros/components
import KlerosEscrow from "@kleros/components/kleros-escrow";
//...

Constructs a KlerosEscrow instance.

Name
Type
Description
Default
web3*
Web3
A Web3 instance.
archon
Archon
An Archon instance.
new Archon(web3.currentProvider, "https://ipfs.kleros.io")

A KlerosEscrow instance.

A promise for the current account of the set Web3 instance or the one chosen in the prompt to connect when none is set.

Sets the court and currency that escrow transactions will use.

Name
Type
Description
Default
court
string
The court that will rule over any disputes arising from a transaction. "general" or "blockchain-non-technical", or a custom arbitrable transaction contract address.
"blockchain-non-technical"
currency
string
The address of the token the transaction should be paid in. Leave this undefined to use ETH.

A promise that resolves when the court and currency are set.

Uploads files to Kleros' IPFS node.

Name
Type
Description
Default
Text
Text
fileName*
string
The file name of the file to upload.
bufferOrJSON*
`string
Buffer
object`
The file to upload.

A promise for the uploaded's file IPFS URI.

Gets the list of transactions an address is involved in.

Name
Type
Description
Default
address
string
The address to get transactions for.
(await web3.eth.getAccounts())[0]

A promise for the list of transactions.

Checks if the current Web3 account is the sender of a transaction.

Name
Type
Description
Default
transactionID*
string
The ID of the transaction.

A promise for the answer.

Creates an escrow transaction.

Name
Type
Description
Default
Text
Text
amount*
`number
string
BN`
The amount escrowed.
recipient*
string
The address of the recipient.
timeout*
`number
string
BN`
The time in seconds until the transaction becomes executable.
metaEvidence*
object
The meta evidence object for any potential disputes arising. You can add an additional file property with a buffer, string, or object, and it will be uploaded to IPFS and fileURI will be set appropiately.

A promise for the transaction's creation transaction.

Pays an amount of an escrowed transaction the current account is a sender in, to the recipient.

Name
Type
Description
Default
Text
Text
transactionID*
string
The ID of the transaction.
amount*
`number
string
BN`
The amount to pay.

A promise for the payment's transaction.

Pays an amount of an escrowed transaction the current account is a recipient in, to the sender.

Name
Type
Description
Default
Text
Text
transactionID*
string
The ID of the transaction.
amount*
`number
string
BN`
The amount to pay.

A promise for the payment's transaction.

Executes a transaction where the timeout has passed.

Name
Type
Description
Default
transactionID*
string
The ID of the transaction.

A promise for the execution's transaction.

Timesout the other party of an escrowed transaction the current account is involved in. This is for when they miss the deadline to pay arbitration fees.

Name
Type
Description
Default
transactionID*
string
The ID of the transaction.

A promise for the timeout's transaction.

Pays arbitration fees for a transaction the current account is involved in.

Name
Type
Description
Default
Text
Text
transactionID*
string
The ID of the transaction.
amount*
`number
string
BN`
The amount to pay.

A promise for the payment's transaction.

Uploads evidence to Kleros' IPFS node and submits it for a transaction.

Name
Type
Description
Default
transactionID*
string
The ID of the transaction.
evidence*
object
The evidence object for any potential disputes arising. You can add an additional file property with a buffer, string, or object, and it will be uploaded to IPFS and fileURI will be set appropiately.

A promise for the submission's transaction.
Copy link
Edit on GitHub
On this page
Methods
constructor
Params (web3, archon)
Returns (KlerosEscrow)
klerosEscrow.getAccount
Returns (Promise<object>)
klerosEscrow.setCourtAndCurrency
Params (court = "blockchain-non-technical", currency)
Returns (Promise)
klerosEscrow.upload
Params (fileName, bufferOrJSON)
Returns (Promise<string>)
klerosEscrow.getTransactions
Params (address)
Returns (Promise<object[]>)
klerosEscrow.isSender
Params (transactionID)
Returns (Promise<boolean>)
klerosEscrow.createTransaction
Params (amount, recipient, timeout, metaEvidence)
Returns (Promise<object>)
klerosEscrow.pay
Params (transactionID, amount)
Returns (Promise<object>)
klerosEscrow.reimburse
Params (transactionID, amount)
Returns (Promise<object>)
klerosEscrow.executeTransaction
Params (transactionID)
Returns (Promise<object>)
klerosEscrow.timeout
Params (transactionID)
Returns (Promise<object>)
klerosEscrow.payArbitrationFee
Params (transactionID, amount)
Returns (Promise<object>)
klerosEscrow.submitEvidence
Params (transactionID, evidence)
Returns (Promise<object>)