# 提款/提幣回調

要接收回調，請確保您在 AkashicPay.com 上註冊了您的 URL。您可以接收 「待定」、「已確認」 和 「失敗」 狀態的交易回調。我們建議您設定所有三種狀態，不過如果需要的話，您可以跳過「待定」狀態。只有狀態為 「已確認」 或 「失敗」 的交易才是最終交易。

注意：如果回調的回應狀態代碼 (status code) >= 400，則回調最多會重試 15 次，延遲時間會增加，第一次嘗試後最多可延遲 10 小時左右。

注意： `l2Txnhash`（「L2-hash」）應始終用作交易的唯一識別碼 (identifier)。這是 [AkashicChain](/traditional-chinese/jian-jie/shu-yu.md#akashicchain) 上任何交易的唯一交易哈希 (transaction-hash)。它存在於已確認的存款和待定/已確認的提款中。這對於第二層交易尤其重要，因為[第二層](/traditional-chinese/jian-jie/shu-yu.md#di-er-ceng-layer2)交易沒有第一層哈希值 (`txHash`)

> 注意：在重新嘗試呼叫回調時，系統僅會將請求發送至原始回調建立時所設定的回調網址。任何在首次嘗試後新增的回調網址，或對現有回調網址所做的變更，均不會在重新嘗試過程中被採用。

> 注意：雖然我們的目標是在 Akashic 的穩定性和一致性，我們不能保證下面的對象保持不變。舉例來說，新的功能可能需要在回調中加入額外的欄位。然而，我們的目標是不移除現有的欄位。為了方便起見，我們建議根據您的需求過濾和處理回調，同時對未來新增的可能性持開放態度。

## <mark style="color:blue;">範例</mark>

### <mark style="color:blue;">待提款/提幣 (L1Transaction)</mark>

```json
 {
  "fromAddress": "TTVkK6hGoAFhALG9NTkUDHjcFFXKmWcScU", // sending wallet/account of transaction
  "toAddress": "TQH8ygbS8BAnzSQ9uxR9vXHJYMQVRvbgPg", // receiving wallet/account of transaction
  "layer": "L1Transaction", // 'L1Transaction' or 'L2Transaction'
  "initiatedAt": "2024-08-19T10:02:54.000Z", // ISO8601 format
  "amount": "1.000000",  // Amount sent
  "coinSymbol": "TRX", // NetworkSymbol, e.g. 'ETH' or 'TRX'
  "status": "Confirmed", // TransactionStatus. 'Pending', 'Confirmed', or 'Failed'
  "txHash": "28a9880ad2ef3b7be1c40763128ec9630ab74e4749a3c81037c3501e4209bfcc", // Network's hash if L1. Not present for L2
  "feesEstimate": "6.114654", // Gas fee estimated by Akashic. Not present for L2
  "l2TxnHash": "ASe7eb1cb8193787040fcffa02a224a6ced7415ff2205343c0ab661e898e8d6eef", // Akashic Transaction Hash. For both L1 and L2 
  "senderInfo": {
    "identity": "ASbb8efead2d5ff2f618a85895bac8e8ac1bae236d4d730bf113400b7e6f108ca5", // Akashic Address of sender
  },
  "senderIdentity": "ASbb...", // DEPRECATED. Same as above. Please use senderInfo.identity instead
  "tokenSymbol": "USDT", // TokenSymbol. Present only if token-transaction
  "internalFee": {
    "withdraw": "0.100000"
  }, // Akashic Fee { deposit?: string, withdraw?: string}
   "referenceId": "tx123", // txn-identifier
   "feeIsDelegated": false, // Whether L1 gas fees were paid using token instead of native coin
   "directResolution": false // true if the transaction was never registered in the "Pending" state
}
```

### <mark style="color:blue;">提款/提幣 (L1Transaction)</mark>

```json
  {
  "fromAddress": "TTVkK6hGoAFhALG9NTkUDHjcFFXKmWcScU", // sending wallet/account of transaction
  "toAddress": "TQH8ygbS8BAnzSQ9uxR9vXHJYMQVRvbgPg", // receiving wallet/account of transaction
  "layer": "L1Transaction", // 'L1Transaction' or 'L2Transaction'
  "initiatedAt": "2024-08-19T10:02:54.000Z", // ISO8601 format
  "confirmedAt": "2024-08-19T10:04:02.000Z", // Only present if status is 'Confirmed' or 'Failed'
  "amount": "1.000000",  // Amount sent
  "coinSymbol": "TRX", // NetworkSymbol, e.g. 'ETH' or 'TRX'
  "status": "Confirmed", // TransactionStatus. 'Pending', 'Confirmed', or 'Failed'
  "txHash": "28a9880ad2ef3b7be1c40763128ec9630ab74e4749a3c81037c3501e4209bfcc", // Network's hash if L1. Not present for L2
  "feesEstimate": "6.114654", // Gas fee estimated by Akashic. Not present for L2
  "feesPaid": "5.822220", // Gas Fee paid on network. Not present for L2
  "l2TxnHash": "ASe7eb1cb8193787040fcffa02a224a6ced7415ff2205343c0ab661e898e8d6eef", // Akashic Transaction Hash. For both L1 and L2 
  "senderInfo": {
    "identity": "ASbb8efead2d5ff2f618a85895bac8e8ac1bae236d4d730bf113400b7e6f108ca5", // Akashic Address of sender
  },
  "senderIdentity": "ASbb...", // DEPRECATED. Same as above. Please use senderInfo.identity instead
  "tokenSymbol": "USDT", // TokenSymbol. Present only if token-transaction
  "internalFee": {
    "withdraw": "0.100000"
  }, // Akashic Fee { deposit?: string, withdraw?: string}
   "referenceId": "tx123", // txn-identifier
   "feeIsDelegated": false, // Whether L1 gas fees were paid using token instead of native coin
   "directResolution": false // true if the transaction was never registered in the "Pending" state
}

```

對於待處理交易，`feesPaid` 和 `confirmedAt` 尚未知道，因此不存在。

#### *<mark style="color:blue;">關於提款費用的說明</mark>*

提款時，有幾種不同的費用。這些是：

* Akashic 費用 (回調中的 `internalFee.withdraw`)，總是與交易貨幣相同。例如，E**TH 轉帳用 ETH，USDT 轉帳用 USDT，USDC 轉帳用 USDC，等等。除非發生「費用代令」，否則通常為 0，請參閱下文。**
* [礦工費](/traditional-chinese/jian-jie/shu-yu.md#fei-yong-kuang-gong-fei) (回調中的 `feesPaid`)，總是以[原生幣](/traditional-chinese/jian-jie/shu-yu.md#huo-bi)計算 (例如 ETH 代表 ERC20 USDT 或 USDC 轉帳，TRX 代表 TRC20 USDT 轉帳，BNB 代表 BEP20 USDT 或 USDC 轉帳等)。由 [L1 網路](/traditional-chinese/jian-jie/shu-yu.md#di-yi-ceng-layer1)收取 (以太坊 (Ethereum)、波場 (Tron)、幣安智能鏈 (BNB Smart Chain (BSC)) 和索拉拉 (Solana) 等)
* 「費用代付」。Akashic 系統讓您用代幣而非原生幣來支付上述的原生費用，以簡化問題。如果這樣做，`feeIsDelegated` 將會在回調中為 <kbd>true</kbd>。所有使用 SDK 完成的提款都應該是 「代付」 的，而從 [AkashicLink](/traditional-chinese/jian-jie/shu-yu.md#akashiclink) 啟動的提款預設不會是 「代付」的。「代付」 費用所需的額外代幣金額在 `internalFee.withdraw` 中。

利用這一點，我們可以計算使用者花費的總金額（假設上圖所示的回調資料在 `txCallback` 中）：

```typescript
// Token transaction (USDT)
if (txCallback.tokenSymbol) {
    userTokenSpent = txCallback.amount + txCallback.internalFee.withdraw;
    // If fee is not delegated, gas fees are paid in native coin
    if (!feeIsDelegated) {
        userNativeCoinSpent = txCallback.feesPaid;
    }
} else {
// Coin transaction (ETH, TRX)
    userNativeCoinSpent = txCallback.amount + txCallback.internalFee.withdraw 
        + txCallback.feesPaid;
}

```

請注意，以上是偽碼。您可能需要額外注意處理潛在的未定義/空值（如 `internalFee`），並根據您所選程式語言的一般慣例，安全正確地解析數字。

### <mark style="color:blue;">提款/提幣 (L2Transaction)</mark>

如果使用者要傳送資產給 Akashic 系統中的其他使用者，則會在 AkashicChain 中執行，這是我們的第 2 層區塊鏈，可降低第一層的礦工費和成本。

```json
{
  "initiatedAt": "2024-08-19T10:03:58.649Z",
  "confirmedAt": "2024-08-19T10:03:58.649Z",
  "fromAddress": "AS3ce733d2af1ee530e0e85bd7de45c59626b28f95ac2d8e83a0685a70aac9b764", // Same as senderIdentity
  "toAddress": "AS188689e48494c8a452683587138f209d673aada204cb23393140e7f40280e0c5", // Same as receiverIdentity
  "coinSymbol": "TRX-SHASTA",
  "status": "Confirmed", // "Confirmed" or "Failed"
  "layer": "L2Transaction", // Could be "L2Transaction" here
  "amount": "10.000000",
  "internalFee": {
    "withdraw": "0.100000" // Akashic-fee, not present if Failed
  },
  "l2TxnHash": "ASe7eb1cb8193787040fcffa02a224a6ced7415ff2205343c0ab661e898e8d6eef", // AkashicChain txHash
  "receiverInfo": {
    "identity": "AS188689e48494c8a452683587138f209d673aada204cb23393140e7f40280e0c5", // Akashic Address of receiver
  },
  "receiverIdentity": "AS18...", // DEPRECATED. Same as above. Please use receiverInfo.identity instead
  "tokenSymbol": "USDT", // Only here if a token-transaction,
  "referenceId": "tx123", // txn-identifier
  "senderInfo": {
    "identity": "AS3ce733d2af1ee530e0e85bd7de45c59626b28f95ac2d8e83a0685a70aac9b764", // Akashic Address of sender
  },
  "senderIdentity": "AS3c..." // DEPRECATED. Same as above. Please use senderInfo.identity instead
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.akashicpay.com/traditional-chinese/hui-diao/ti-kuan-ti-bi-hui-diao-payout-callback.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
