request_onchain_funds
The user has to initiate transfer to the anchor
Params
(10)Please note that parameter structure within the request must contain named parameters as a by-name object, and not as positional arguments in a by-position array
1. transaction_id (required)
The unique identifier of this transaction.
A unique transaction identifier.
2. message
Human readable explanation of transaction status.
A human readable message.
3. amount_in (required)
The amount expected in the payment
A numerical representation of an amount of some asset.
The asset to be received by the Anchor
4. amount_out (required)
Amount sent by anchor to user
A numerical representation of an amount of some asset.
The asset to be sent by anchor to user at end of transaction
5. amount_fee
DEPRECATED in favor of fee_details. Amount of fee charged by anchor
A numerical representation of an amount of some asset.
6. fee_details (required)
Description of fees charged by the anchor
Description of fee charged by the anchor.
Details about fee charged.
7. amount_expected
The amount expected in the payment
A numerical representation of an amount of some asset.
8. destination_account
Destination account
9. memo
Value of memo to attach to transaction
10. memo_type
Type of memo that anchor should attach to the transaction
Result
(request_onchain_fundsResponse)A unique transaction identifier.
Protocol of the transaction.
The kind of transaction that is desired.
Processing status of the transaction.
The amount expected in the payment.
A stringified amount of an asset.
An asset.
Amount expected/received by anchor.
A stringified amount of an asset.
An asset.
The amount expected to be sent by anchor to user at end of transaction.
A stringified amount of an asset.
An asset.
DEPRECATED in favour of fee_details. The total amount charged in fees for processing all refund payments, in units of amount_in_asset.
A stringified amount of an asset.
An asset.
Description of fee charged by the anchor.
Details about fee charged.
The id returned from a SEP-38 POST /quote response
Start date and time of transaction.
The date and time of transaction reaching the current status.
The date and time of transaction reaching completed or refunded status.
The date and time of receiving transfer.
Human readable explanation of transaction status
An object describing any on or offchain refund associated with this transaction.
The total amount refunded in units of amount_in_asset.
The total amount charged in fees for processing all refund payments, in units of amount_in_asset.
A list of objects containing information on the individual payments made back as refunds.
Example
Example request to the request_onchain_funds
method.
Request
- cURL
- JavaScript
- Python
- JSON
curl -X POST \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 8675309,
"method": "request_onchain_funds",
"params": {
"transaction_id": "1c186184-09ee-486c-82a7-aa7a0ab1119d",
"message": "Requesting onchain funds",
"amount_in": {
"amount": 1,
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_out": {
"amount": 0.9,
"asset": "iso4217:USD"
},
"amount_fee": {
"amount": 0.1,
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_expected": {
"amount": 1
}
}
}' \
https://platform-server.exampleanchor.com | jq
let requestBody = {
"jsonrpc": "2.0",
"id": 8675309,
"method": "request_onchain_funds",
"params": {
"transaction_id": "1c186184-09ee-486c-82a7-aa7a0ab1119d",
"message": "Requesting onchain funds",
"amount_in": {
"amount": 1,
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_out": {
"amount": 0.9,
"asset": "iso4217:USD"
},
"amount_fee": {
"amount": 0.1,
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_expected": {
"amount": 1
}
}
}
let res = await fetch('https://platform-server.exampleanchor.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
})
let json = await res.json()
console.log(json)
import json, requests
res = requests.post('https://platform-server.exampleanchor.com', json={
"jsonrpc": "2.0",
"id": 8675309,
"method": "request_onchain_funds",
"params": {
"transaction_id": "1c186184-09ee-486c-82a7-aa7a0ab1119d",
"message": "Requesting onchain funds",
"amount_in": {
"amount": 1,
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_out": {
"amount": 0.9,
"asset": "iso4217:USD"
},
"amount_fee": {
"amount": 0.1,
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_expected": {
"amount": 1
}
}
})
print(json.dumps(res.json(), indent=4))
{
"jsonrpc": "2.0",
"id": 8675309,
"method": "request_onchain_funds",
"params": {
"transaction_id": "1c186184-09ee-486c-82a7-aa7a0ab1119d",
"message": "Requesting onchain funds",
"amount_in": {
"amount": 1,
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_out": {
"amount": 0.9,
"asset": "iso4217:USD"
},
"amount_fee": {
"amount": 0.1,
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_expected": {
"amount": 1
}
}
}
Result
{
"jsonrpc": "2.0",
"id": 8675309,
"result": {
"id": "1c186184-09ee-486c-82a7-aa7a0ab1119d",
"sep": "24",
"kind": "deposit",
"status": "completed",
"amount_expected": {
"amount": "1",
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_in": {
"amount": "1",
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"amount_out": {
"amount": "0.9",
"asset": "iso4217:USD"
},
"amount_fee": {
"amount": "0.1",
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"started_at": "2023-08-04T10:04:06.280923Z",
"updated_at": "2023-08-04T10:04:15.716233Z",
"message": "Transaction complete",
"source_account": "GB4GJAV4Q7DPGU7WI3H5TMVKEYZJ4JFLFEF3O3TRJKDPXK7NAMRBXWFL",
"destination_account": "GDIN5ZULIOT5YPBIXJXFGNH4TCNTDKIA4ZF6QQE3S2P5P44BHCQQJNDC"
}
}