Payments

The payment endpoint is used for transferring tokens to another node. You can send the desired amount of tokens by providing the address of the token and the address of the receiving node.

Payments Resource Overview

HTTP Method

Resource

Description

GET

Payment history

POST

Initiate a payment

Payment Resource Details

Payment History

GET http://localhost:5001/api/v1/payments/0x0f11...b1ED/0x8264...5ba7

When querying the payment history the response will include: - "EventPaymentSentSuccess" for successful payments - "EventPaymentSentFailed" for failed payments - "EventPaymentReceivedSuccess" for received payments

Path Parameters

Name
Type
Description

version

string

Version of the API

token_address

string

Address of a token, will filter response list according to token_address

partner_address

string

Address of either the payment initiator or target, will filter response list according to the address

Query Parameters

Name
Type
Description

?limit=

integer

Limits the payment history result to the amount specified after =

&offset=

integer

Offsets the payment history result by the amount specified after =

[
    {
        "event": "EventPaymentSentSuccess",
        "amount": "20",
        "target": "0x82641569b2062B545431cF6D7F0A418582865ba7",
        "identifier": "3",
        "log_time": "2018-10-30T07:10:13.122",
        "token_address": "0x62083c80353Df771426D209eF578619EE68D5C7A"
    },
    {
        "target": "0x82641569b2062B545431cF6D7F0A418582865ba7",
        "event": "EventPaymentSentFailed",
        "log_time": "2018-10-30T07:04:22.293",
        "reason": "there is no route available",
        "token_address": "0x62083c80353Df771426D209eF578619EE68D5C7A"
    },
    {
        "event": "EventPaymentReceivedSuccess",
        "amount": "5",
        "initiator": "0x82641569b2062B545431cF6D7F0A418582865ba7",
        "identifier": "1",
        "log_time": "2018-10-30T07:03:52.193",
        "token_address": "0x62083c80353Df771426D209eF578619EE68D5C7A"
    }
]

Initiate a Payment

POST http://localhost:5001/api/v1/payments/0x2a65...8226/0x61C8...0bD9

The request might take some time and will only return once the payment either succeeds or fails.

Path Parameters

Name
Type
Description

version

string

Version of the API

token_address

string

Address of a token

target_address

string

Address of the receiving node

Request Body

Name
Type
Description

amount

string

Amount of tokens to be sent

identifier

string

Integer for identifying the payment

{
    "initiator_address": "0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8",
    "target_address": "0x61C808D82A3Ac53231750daDc13c777b59310bD9",
    "token_address": "0x2a65Aca4D5fC5B5C859090a6c34d164135398226",
    "amount": "200",
    "identifier": "42"
}

Example request body:

{
    "amount": "200",
    "identifier" "42"
}

Failing Payments

A payment can fail due to:

  • The secret for opening the hashlock not being revealed in time and the lock expires

  • The target node being offline

  • The channels leading to the target node not having enough settle timeout and reveal_timeout

  • The funds not being enough

Last updated

Was this helpful?