From fc61828f913ed79cd3d981859bd2ed307fe76335 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 2 Mar 2026 12:28:14 +0100 Subject: [PATCH] docs: add Internet Computer (ICP) integration to README (#55) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: add Internet Computer (ICP) integration to README - Add InternetComputer method with ICP, ckBTC, ckETH, ckUSDC, ckUSDT assets to transferAmounts example - Add ICP transaction details JSON example (ICRC-2 approve flow) - Add Internet Computer section in Step 4 with both payment flows: - Option A: ICRC-2 Approve (recommended) - approve + sender parameter - Option B: Direct Transfer (TxId) - broadcast + tx parameter - Add sender query parameter to Important box * fix: correct ICP URI format and add asset parameter - URI schema: icp: → internetComputer:, amount as decimal, address after schema - Add &asset=ICP to all ICP example URLs (required for multi-asset methods) - Update Option A instructions to match new URI format Addresses review feedback from @bernd2022 * fix: typo 'prove' → 'proof', add asset parameter to docs - Fix typo: 'transaction prove' → 'transaction proof' - Add 'asset' to the Important query parameters list (required for ICP) * fix: correct ICP URI scheme from 'internetComputer:' to 'icp:' per API implementation --------- Co-authored-by: Nanobot Co-authored-by: max-tech-bot --- README.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ca6a7e3..0db1541 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,33 @@ A GET HTTP call to either of these endpoints will return a JSON with the followi "minFee": 0, "assets": [], "available": false + }, + { + "method": "InternetComputer", + "minFee": 0, + "assets": [ + { + "asset": "ICP", + "amount": "0.08415" + }, + { + "asset": "ckBTC", + "amount": "0.00001069" + }, + { + "asset": "ckETH", + "amount": "0.00040256" + }, + { + "asset": "ckUSDC", + "amount": "1.261582" + }, + { + "asset": "ckUSDT", + "amount": "1.26157" + } + ], + "available": true } ] } @@ -269,6 +296,14 @@ A GET HTTP call to this endpoint will return a JSON with the following structure "hint": "Use this data to create a transaction and sign it. Send the signed transaction back as HEX via the endpoint https://api.dfx.swiss/v1/lnurlp/tx/plp_f1ba466e2f1c0a4e. We check the transferred HEX and broadcast the transaction to the blockchain." } +// Internet Computer (ICP) +{ + "expiryDate": "2025-05-01T14:34:40.881Z", + "blockchain": "InternetComputer", + "uri": "icp:6bf47-...-cai?amount=0.08415", + "hint": "Approve the address from the URI for the required amount plus transfer fee using icrc2_approve. Then send your Principal ID as the sender parameter via the endpoint https://api.dfx.swiss/v1/lnurlp/tx/plp_f1ba466e2f1c0a4e." +} + // Lightning { "pr": "lnbc12590n1p5p8p66pp5eh5manf8yj39ktlfm7h9y4uzph0wjnt6ngu2c709s9z5wndrfxkshp5kyucf7yxx97e0axrwke7xdy599csdhy67jd5pysz2n3m4d636cgqcqzzsxqzgvsp5wl7m20pwux8p49cumznt2vk3p6x08h0vshnpf2ckqzkwfw6fjdms9qyyssqy4mtye0fekxpgcjftmtqqre43xewmnsu94xmkq4yr8yfuj8se4ynd57s3etcdt3qwrrzx9x2qfm0kpz6kj9wy6ys328znrdvsq6mzrcpw0nfqs" @@ -281,13 +316,15 @@ Please note that the transaction details received belong to the quote from [step The transaction details received in [step 3](#3-transaction-details) should now be used to construct the blockchain transaction. This process depends on the selected method. Please make sure to use a transaction fee higher or equal to the minimum fee specified in the `minFee` field (gas price in WEI for EVM chains, sat/vB for Bitcoin) for the specific payment method (in JSON from [step 2](#2-payment-details)). -The API URL to send the transaction prove back to the payment provider (see below) can be constructed by using the callback URL from [step 3](#3-transaction-details) and replacing `/cb` with `/tx`. +The API URL to send the transaction proof back to the payment provider (see below) can be constructed by using the callback URL from [step 3](#3-transaction-details) and replacing `/cb` with `/tx`. **Important:** All transaction submission endpoints require the following query parameters: - `quote`: The quote ID from [step 2](#2-payment-details) - `method`: The blockchain/payment method name (must match exactly the method name from the `transferAmounts` array, e.g., "Ethereum", "BinanceSmartChain", "Polygon", etc.) - `hex`: The raw signed transaction in hexadecimal format - `tx`: The transaction ID after broadcasting (only for Monero and certain other blockchains) +- `asset`: The asset name (required for Internet Computer, e.g. "ICP", "ckBTC", "ckUSDC") +- `sender`: The sender's Principal ID (only for Internet Computer ICRC-2 approve flow) #### EVM and Bitcoin @@ -305,6 +342,26 @@ Use the `uri` field from [step 3](#3-transaction-details) to construct a valid t In our example the URL would be https://api.dfx.swiss/v1/lnurlp/tx/plp_f1ba466e2f1c0a4e?quote={quote-id}&method=Monero&hex={raw-tx-hex}&tx={tx-id}. +#### Internet Computer (ICP) + +The Internet Computer supports two payment flows: + +**Option A: ICRC-2 Approve (recommended)** + +1. Parse the `uri` field from [step 3](#3-transaction-details) to extract the payment provider's Principal (the address directly after `icp:`) and the amount. +2. Call `icrc2_approve` on the token canister, approving the payment provider's Principal for the required amount plus the transfer fee. +3. Send your Principal ID to the payment provider with a GET HTTP request to the URL specified above, using the `sender` parameter instead of `hex` or `tx`. + +In our example the URL would be https://api.dfx.swiss/v1/lnurlp/tx/plp_f1ba466e2f1c0a4e?quote={quote-id}&method=InternetComputer&asset=ICP&sender={principal-id}. + +The payment provider will then execute `icrc2_transfer_from` to pull the approved amount. If the call returns a success HTTP code, the payment has been successfully completed. + +**Option B: Direct Transfer (TxId)** + +Alternatively, construct and broadcast a transfer transaction (ICP transfer or `icrc1_transfer` for ICRC-1 tokens) directly to the address specified in the `uri` field. Then send the transaction ID to the payment provider. + +In our example the URL would be https://api.dfx.swiss/v1/lnurlp/tx/plp_f1ba466e2f1c0a4e?quote={quote-id}&method=InternetComputer&asset=ICP&tx={tx-id}. + #### Lightning Use the invoice from the `pr` field from [step 3](#3-transaction-details) to execute the transaction. The Open CryptoPay payment will be completed as soon as the transaction has been successfully executed.