Posted By : Harshit
Introduction
SEP 24 defines the protocol for anchor and wallet to interact. It improves the user experience by enabling clients to interact with an anchor directly through a wallet. It supports interactive flow. It defines protocols for features like deposit, withdrawal, transaction status, history, KYC, etc. The location of an anchor must be defined in the toml file and anchor, as well as the client must support SEP 10 authentication for withdraws, deposit, and transaction history. The client must submit the token in all API calls except /info endpoint and token must include in headers. CORS must be enabled on the server for the API calls.
Deposit
It is a process when a user wants to send assets to another user on the anchor. This endpoint allows the wallet to get information regarding the deposit from the anchor. If the given user account does not exist on the deposit side then the anchor has to use create_account to create the new account with the minimum XLMs. If the anchor doesn't have the endpoint create_account then it must return a bad request error with the reason for the failure of the transaction.
Withdraw
This is the operation to redeem an asset on the stellar network for the real asset by a stellar anchor. The endpoint allows the wallet to get withdrawl information from the anchor to initiate the withdrawal. There are many kinds of responses that depend on the need of user information by the anchor.
Following is the flow for deposit and withdraw transactions.
Info
This endpoint enables the anchor to communicate for the basic information of a user. It contains 3 parameters, one is the deposit, one for withdrawl, and one flag for fee. Deposit includes the assets and its details like fee, fee per cent, min amount, max amount and a flag to check that particular operation is enabled or not. Another one is withdrawl, it also includes the details of assets and a flag to check that particular operation is enabled on it or not. The third is fee, if the asset details consist of fee_fixed and fee_percentage then fee can be calculated by (amount*fee_percent) + fee_fixed otherwise fee can be got by /fee endpoint.
Fee
This endpoint provides the fee which has to be applied on deposit and withdraw functionality. Fee can be calculated for particular assets but the fields like fee_fixed, fee_percent and fee_minimum which are present in the /info endpoint. The endpoint throws the error if the asset is not registered on the anchor like{"˜error':'This anchor does not support the given currency code: ETH'}.
Transaction history
This endpoint (/transactions) provides the history of past deposit or withdrawal transactions. It provides the history of transactions that are done from the same anchor. It requires valid JWT in request to get the history. It provides an array of transactions and each transaction includes the details like id, kind, status, amount_in, started_at, stellar_transaction_id etc. Some fields are differentiated like in deposit transaction response some fields are included like deposit_memo, deposit_memo_type, from, to, etc and in withdraw transaction, withdraw_anchor_account, withdraw_memo, to, from etc. fields are included.
Changes from SEP 6
Conclusion
In this blog, we learned about SEP 24 stellar protocol. It explains the flow of withdraw and deposit. It also explains the usage of fee and help ton understand the changes from SEP 6.
Reference
Official document - https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md
November 18, 2024 at 01:43 pm
Your comment is awaiting moderation.