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-erc20-fee-proxy-contract-0.1.0.md
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,18 @@
2
2
3
3
## Description
4
4
5
-
This extension allows payments and refunds to be made in ERC20 tokens on Ethereum and EVM-compatible blockchains.
5
+
This extension allows payments and refunds to be made in fungible tokens, including:
6
+
7
+
- ERC20 tokens on Ethereum and EVM-compatible blockchains.
8
+
- Fungible tokens on Near and Near testnet (as defined by NEP-141 and NEP-148)
9
+
6
10
This Payment Network is similar to the [ERC20 Proxy Contract](./payment-network-erc20-proxy-contract-0.1.0.md) extension, with the added feature of allowing a fee to be taken from the payment.
7
11
8
12
The payment is mainly expected through a proxy payment contract, but the request issuer can also declare payments manually. Fees shall not be paid for declarative payments.
9
13
10
-
The proxy contract does the ERC20 token transfer on behalf of the user. The contract ensures a link between an ERC20 transfer and a request through a `paymentReference`. This `paymentReference` consists of the last 8 bytes of a salted hash of the requestId: `last8Bytes(hash(lowercase(requestId + salt + address)))`:
14
+
The proxy contract does the fungible token transfer on behalf of the user. The contract ensures a link between a token transfer and a request through a `paymentReference`. This `paymentReference` consists of the last 8 bytes of a salted hash of the requestId: `last8Bytes(hash(lowercase(requestId + salt + address)))`:
11
15
12
-
The contract also ensures that the `feeAmount` amount of the ERC20 transfer will be forwarded to the `feeAddress`.
16
+
The contract also ensures that the `feeAmount` amount of the token transfer will be forwarded to the `feeAddress`.
13
17
14
18
-`requestId` is the id of the request
15
19
-`salt` is a random number with at least 8 bytes of randomness. It must be unique to each request
@@ -24,7 +28,7 @@ As a payment network, this extension allows to deduce a payment `balance` for th
24
28
25
29
## Payment Proxy Contract
26
30
27
-
The contract contains one function called `transferFromWithReferenceAndFee` which takes 6 arguments:
31
+
On EVMs, the contract contains one function called `transferFromWithReferenceAndFee` which takes 6 arguments:
28
32
29
33
-`tokenAddress` is the address of the ERC20 contract
30
34
-`to` is the destination address for the tokens
@@ -33,9 +37,14 @@ The contract contains one function called `transferFromWithReferenceAndFee` whic
33
37
-`feeAmount` is the amount of tokens to transfer to the fee destination address
34
38
-`feeAddress` is the destination address for the fee
35
39
36
-
The `TransferWithReferenceAndFee` event is emitted when the tokens are transfered. This event contains the same 6 arguments as the `transferFromWithReferenceAndFee` function.
40
+
On Near, users send fungible tokens to the contract with the `ft_transfer_call` method, if the `msg` value given is a valid JSON object with 4 of the 6 arguments listed above: `to`, `paymentReference`, `feeAmount` and `feeAddress`. The `tokenAdress` is taken from the calling fungible token contract. The `amount` is equal to the transfer (total) `amount` less `feeAmount`.
41
+
42
+
On EVM-compatible chains, the `TransferWithReferenceAndFee` event is emitted when the tokens are transfered. This event contains the same 6 arguments as the `transferFromWithReferenceAndFee` function.
0 commit comments