Skip to content

Commit 5894f42

Browse files
authored
Update escrow-sdk.md
1 parent a569f98 commit 5894f42

File tree

1 file changed

+187
-4
lines changed

1 file changed

+187
-4
lines changed

integrations/integration-tools/escrow-sdk.md

Lines changed: 187 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,200 @@
22
description: A class that lets you create and manage Kleros Escrow transactions.
33
---
44

5+
56
# Escrow SDK
67

7-
Use this Kleros Escrow SDK to easily integrate on-chain escrow features on your platform.
8+
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.
89

9-
```text
10+
```js
1011
import KlerosEscrow from "@kleros/components/kleros-escrow";
1112

1213
//...
1314
```
1415

15-
Check out all the methods available in the docs below.
16+
## Methods
17+
18+
## `constructor`
19+
20+
Constructs a `KlerosEscrow` instance.
21+
22+
#### Params `(web3, archon)`
23+
24+
| Name | Type | Description | Default |
25+
| ------ | -------- | ----------------------------------------------------- | ------------------------------------------------------------ |
26+
| web3\* | `Web3` | A Web3 instance. | |
27+
| archon | `Archon` | An [Archon](https://archon.readthedocs.io/) instance. | `new Archon(web3.currentProvider, "https://ipfs.kleros.io")` |
28+
29+
#### Returns `(KlerosEscrow)`
30+
31+
A `KlerosEscrow` instance.
32+
33+
## `klerosEscrow.getAccount`
34+
35+
#### Returns `(Promise<object>)`
36+
37+
A promise for the current account of the set Web3 instance or the one chosen in the prompt to connect when none is set.
38+
39+
## `klerosEscrow.setCourtAndCurrency`
40+
41+
Sets the court and currency that escrow transactions will use.
42+
43+
#### Params `(court = "blockchain-non-technical", currency)`
44+
45+
| Name | Type | Description | Default |
46+
| -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
47+
| 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](https://github.com/kleros/escrow-contracts) address. | `"blockchain-non-technical"` |
48+
| currency | `string` | The address of the token the transaction should be paid in. Leave this undefined to use ETH. | |
49+
50+
#### Returns `(Promise)`
51+
52+
A promise that resolves when the court and currency are set.
53+
54+
## `klerosEscrow.upload`
55+
56+
Uploads files to Kleros' IPFS node.
57+
58+
#### Params `(fileName, bufferOrJSON)`
59+
60+
| Name | Type | Description | Default |
61+
| -------------- | -------- | ------------------------------------ | ------- | ------------------- | --- |
62+
| fileName\* | `string` | The file name of the file to upload. | |
63+
| bufferOrJSON\* | `string | Buffer | object` | The file to upload. | |
64+
65+
#### Returns `(Promise<string>)`
66+
67+
A promise for the uploaded's file IPFS URI.
68+
69+
## `klerosEscrow.getTransactions`
70+
71+
Gets the list of transactions an address is involved in.
72+
73+
#### Params `(address)`
74+
75+
| Name | Type | Description | Default |
76+
| ------- | -------- | ------------------------------------ | ----------------------------------- |
77+
| address | `string` | The address to get transactions for. | `(await web3.eth.getAccounts())[0]` |
78+
79+
#### Returns `(Promise<object[]>)`
80+
81+
A promise for the list of transactions.
82+
83+
## `klerosEscrow.isSender`
84+
85+
Checks if the current Web3 account is the sender of a transaction.
86+
87+
#### Params `(transactionID)`
88+
89+
| Name | Type | Description | Default |
90+
| --------------- | -------- | -------------------------- | ------- |
91+
| transactionID\* | `string` | The ID of the transaction. | |
92+
93+
#### Returns `(Promise<boolean>)`
94+
95+
A promise for the answer.
96+
97+
## `klerosEscrow.createTransaction`
98+
99+
Creates an escrow transaction.
100+
101+
#### Params `(amount, recipient, timeout, metaEvidence)`
102+
103+
| Name | Type | Description | Default |
104+
| -------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------- | --- |
105+
| amount\* | `number | string | BN` | The amount escrowed. | |
106+
| recipient\* | `string` | The address of the recipient. | |
107+
| timeout\* | `number | string | BN` | The time in seconds until the transaction becomes executable. | |
108+
| metaEvidence\* | `object` | The [meta evidence object](https://github.com/ethereum/EIPs/issues/1497) 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. | |
109+
110+
#### Returns `(Promise<object>)`
111+
112+
A promise for the transaction's creation transaction.
113+
114+
## `klerosEscrow.pay`
115+
116+
Pays an amount of an escrowed transaction the current account is a sender in, to the recipient.
117+
118+
#### Params `(transactionID, amount)`
119+
120+
| Name | Type | Description | Default |
121+
| --------------- | -------- | -------------------------- | ------- | ------------------ | --- |
122+
| transactionID\* | `string` | The ID of the transaction. | |
123+
| amount\* | `number | string | BN` | The amount to pay. | |
124+
125+
#### Returns `(Promise<object>)`
126+
127+
A promise for the payment's transaction.
128+
129+
## `klerosEscrow.reimburse`
130+
131+
Pays an amount of an escrowed transaction the current account is a recipient in, to the sender.
132+
133+
#### Params `(transactionID, amount)`
134+
135+
| Name | Type | Description | Default |
136+
| --------------- | -------- | -------------------------- | ------- | ------------------ | --- |
137+
| transactionID\* | `string` | The ID of the transaction. | |
138+
| amount\* | `number | string | BN` | The amount to pay. | |
139+
140+
#### Returns `(Promise<object>)`
141+
142+
A promise for the payment's transaction.
143+
144+
## `klerosEscrow.executeTransaction`
145+
146+
Executes a transaction where the timeout has passed.
147+
148+
#### Params `(transactionID)`
149+
150+
| Name | Type | Description | Default |
151+
| --------------- | -------- | -------------------------- | ------- |
152+
| transactionID\* | `string` | The ID of the transaction. | |
153+
154+
#### Returns `(Promise<object>)`
155+
156+
A promise for the execution's transaction.
157+
158+
## `klerosEscrow.timeout`
159+
160+
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.
161+
162+
#### Params `(transactionID)`
163+
164+
| Name | Type | Description | Default |
165+
| --------------- | -------- | -------------------------- | ------- |
166+
| transactionID\* | `string` | The ID of the transaction. | |
167+
168+
#### Returns `(Promise<object>)`
169+
170+
A promise for the timeout's transaction.
171+
172+
## `klerosEscrow.payArbitrationFee`
173+
174+
Pays arbitration fees for a transaction the current account is involved in.
175+
176+
#### Params `(transactionID, amount)`
177+
178+
| Name | Type | Description | Default |
179+
| --------------- | -------- | -------------------------- | ------- | ------------------ | --- |
180+
| transactionID\* | `string` | The ID of the transaction. | |
181+
| amount\* | `number | string | BN` | The amount to pay. | |
182+
183+
#### Returns `(Promise<object>)`
184+
185+
A promise for the payment's transaction.
186+
187+
## `klerosEscrow.submitEvidence`
188+
189+
Uploads evidence to Kleros' IPFS node and submits it for a transaction.
190+
191+
#### Params `(transactionID, evidence)`
192+
193+
| Name | Type | Description | Default |
194+
| --------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
195+
| transactionID\* | `string` | The ID of the transaction. | |
196+
| evidence\* | `object` | The [evidence object](https://github.com/ethereum/EIPs/issues/1497) 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. | |
197+
198+
#### Returns `(Promise<object>)`
16199

17-
📖 [Escrow SDK documentation](https://5fa1b0ad3a9cb90022ca37de-fbcovmppyp.chromatic.com/?path=/story/sdks-klerosescrow--page) 📖
200+
A promise for the submission's transaction.
18201

0 commit comments

Comments
 (0)