payout
Use to send a cryptocurrency transaction.
Make sure the address is formatted correctly and matches the network.
The amount must be a string and should be in the standard currency unit. I.e. ETH (not WEI) and TRX (not SUN)
Token is optional, use only if sending token. E.g. USDT
Example
Sending 100 USDT on Tron to TTVkK6hGoAFhALG9NTkUDHjcFFXKmWcScU
for user123
Return Example
Returns the L2 transaction hash if the transaction is successful. Otherwise, returns an error-code.
Note: l2Txnhash
(the "L2-hash") should always be used as the unique identifier of a transaction. This is a unique transaction-hash for any transaction on AkashicChain. It is present for Confirmed deposits and Pending/Confirmed payouts. This is particularly important for the case of Layer 2 transactions, which will not have a Layer 1 hash (txHash
)
Errors
The function will return a field name error
with an error-code upon any expected failure. Note that an error may still be thrown on any unexpected failure (e.g. network issues causes the transaction-submission to time out). For a full list of all errors, see Errors.
Expect errors returned by the function are:
You do not posses enough funds of the chosen currency to complete the transaction. Re-check your balances.
Usually means you've done something wrong. E.g. trying to send without having created or onboarded your account to AP. Could also indicate unpexpected problems with AP while trying to orchestrate the transaction. Should be rare. Check your details, retry quickly, and contact CS if no solution is found.
If an UNKNOWN_ERROR
is thrown, it could indicate an AkashicChain error. Check the details
of the thrown error for more information. If you have done everything correctly, these errors are usually transient and a retry after a small delay should succeed.
Callback
If a callback URL is registered for payout
on Akashicpay.com, you will receive an HTTP call to that URL with the body like the following:
Note: If the response to the callback has a status code >= 400, the callback is retried up to 15 times with increasing delays up to around 10hrs since the first attempt.
A note on withdrawal fees
There are a few different components in play regarding fees when doing a withdrawal. These are:
Akashic Fee (
internalFee.withdraw
in callback), always in the same currency as the transaction. I.e. ETH for an ETH transfer, USDT for a USDT transfer, etc. Normally 0 unless "fee delegation" happens, see below.Gas Fee (
feesPaid
in callback), always in native coin (e.g. ETH for a ERC20 USDT transfer, TRX for a TRC20 USDT transfer, etc.). Charged by the L1 networks (Ethereum, Tron, etc.)"Fee Delegation". The Akashic system lets you pay for the aforementioned native fee in tokens instead of native coin to simplify matters. If this is done,
feeIsDelegated
will betrue
in the callback. All withdrawals done using the SDK should be "delegated" while withdrawals initating from AkashicLink will not by default. The extra token-amount needed to "delegate" the fee is ininternalFee.withdraw
Using this, to calculate the total amount spent by a user we can do (assuming callback data of the form shown above is in txCallback
):
Note that the above is pseudocode. You would probably need to take extra care of handling potential undefined/null values like internalFee
as well as parse the numbers safely and correctly, following normal practices in your chosen programming language.
Last updated