It looks like you're building a payment verification system for cryptocurrency transactions, specifically focusing on handling swaps and settlements. Here's an overview of the steps involved in creating such a system based on your provided code snippets:
Step-by-Step Guide
-
Get Payment Quote
- This function fetches details about the swap transaction from an external API (e.g., SwapRabbit).
- It includes parameters like
chainId,tokenIn(the token being swapped),amount, andsender.
-
Format Settlement Amounts
- The
formatSettlementfunction converts raw settlement amounts into human-readable formats based on the number of decimals for the settlement token.
- The
-
Server-Side API Endpoint (
POST /get-payment-quote)- This endpoint handles incoming requests from your frontend to get a payment quote.
- It stores the quote in memory (or Redis/database) with an expiry time, typically 30 seconds.
- Returns details like
orderId, settlement amounts, price impact, and transaction data.
-
Verify Payment Execution
- After the customer submits the swap transaction, your backend needs to verify if it was successful.
- This involves checking if the
Read the full article at DEV Community
Want to create content about this topic? Use Nemati AI tools to generate articles, social posts, and more.

![[AINews] The Unreasonable Effectiveness of Closing the Loop](/_next/image?url=https%3A%2F%2Fmedia.nemati.ai%2Fmedia%2Fblog%2Fimages%2Farticles%2F600e22851bc7453b.webp&w=3840&q=75)



