You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/advanced-logic/specs/payment-network-eth-input-data-0.2.0.md
+37-4Lines changed: 37 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,13 @@ Prerequisite: Having read the advanced logic specification (see [here](./advance
10
10
## Description
11
11
12
12
This extension allows the payments and the refunds to be made in Ether on the Ethereum blockchain.
13
-
A payment reference has to be given in input data when making the transfer to link the payment to the request.
13
+
A payment reference has to be given when making the transfer to link the payment to the request.
14
+
15
+
There are two ways to add a payment reference to a transfer:
16
+
17
+
1. add the reference to the input data of the transfer
18
+
2. call the ethereum proxy smart contract (see [Contract](#Contract))
19
+
14
20
The payment reference is the last 8 bytes of a salted hash of the requestId: `last8Bytes(hash(lowercase(requestId + salt + address)))`:
15
21
16
22
-`requestId` is the id of the request
@@ -22,13 +28,29 @@ The payment reference is the last 8 bytes of a salted hash of the requestId: `la
22
28
As a payment network, this extension allows to deduce a payment `balance` for the request. (see
23
29
[Interpretation](#Interpretation))
24
30
31
+
## Contract
32
+
33
+
The contract contains one function called `transferWithReference` which takes 2 arguments:
34
+
35
+
-`to` is the destination address
36
+
-`paymentReference` is the reference data used to track the transfer (see `paymentReference`)
37
+
38
+
The `TransferWithReference` event is emitted when the Ether is transfered. This event contains the same 2 arguments as the `transferWithReference` function plus the `amount` of ethereum sent.
|**values.paymentAddress**|`paymentAddress` from parameters if given, undefined otherwise |
88
110
|**values.refundAddress**|`refundAddress` from parameters if given, undefined otherwise |
@@ -189,6 +211,17 @@ The 'addRefundAddress' event:
189
211
190
212
## Interpretation
191
213
214
+
The proxy contract address is determined by the `request.currency.network` (see (table)[#Contract] with proxy contract addresses).
215
+
192
216
The `balance` starts from `0`.
193
217
Any ETH transaction to `paymentAddress` with exactly `last8Bytes(hash(requestId + salt + payment address))` in input data is considered as a payment. The `balance` is increased by the sum of the amounts of the transactions.
218
+
Any `TransferWithReference` events emitted from the proxy contract with the following arguments are considered as a payment:
219
+
220
+
-`to``===``paymentAddress`
221
+
-`paymentReference``===``last8Bytes(hash(lowercase(requestId + salt + payment address)))`
222
+
194
223
Any ETH transaction to `refundAddress` with exactly `last8Bytes(hash(requestId + salt + refund address))` in input data is considered as a refund. The `balance` is reduced by the sum of the amounts of the transactions.
224
+
Any `TransferWithReference` events emitted from the proxy contract with the following arguments are considered as a refund:
225
+
226
+
-`to``===``refundAddress`
227
+
-`paymentReference``===``last8Bytes(hash(lowercase(requestId + salt + refund address)))`
0 commit comments