Guide

Comprehensive Guide: Requesting a Quote

This guide will walk you through the process of requesting a quote using the bindpay API. This is typically the first step in processing a payment transaction.

What is a Quote Request?

A quote request allows you to get pricing information for a potential transaction before actually executing it. This is useful for:

  1. Showing the user how much they'll pay before they commit

  2. Understanding the current exchange rates and fees

  3. Preparing the necessary transaction details

Prerequisites

Before you start, make sure you have:

  1. A bindpay API key

  2. The details of the transaction you want to quote

If you don't have an API key yet, you can register for one here.

Step-by-Step Guide

1. Prepare Your Request

You'll need to gather the following information:

  • fromChain: The ID of the blockchain network the payment is coming from.

    • Refer to our Active Chains list to find the correct chainID.

    • Example: "1" for Ethereum Mainnet, "8453" for Base

  • fromToken: The address of the token being used for payment.

    • This is a unique address for each token on each network.

    • Example: For ETH on Ethereum, you can use "ETH" or the zero address "0x0000000000000000000000000000000000000000"

  • fromAddress: The wallet address of the person making the payment.

    • This should be a valid address on the specified chain.

    • Example: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e"

  • usdAmount: The amount of the transaction in US Dollars.

    • This should be a string representing the dollar amount.

    • Example: "100" for a $100 transaction

2. Make the API Call

Now that you have all the necessary information, you can make the API call. Here's how to do it using cURL:

curl -X POST "https://api.bindpay.com/v1/quote" \
     -H "Content-Type: application/json" \
     -H "x-api-key: your_api_key_here" \
     -d '{
       "fromChain": "ethereum",
       "fromToken": "ETH",
       "fromAddress": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
       "usdAmount": 100
     }'

Replace your_api_key_here with your actual API key.

3. Understand the Response

The API will respond with a JSON object containing the quote details. Here's an example of what you might receive:

jsonCopy{
  "quoteId": "q_1234567890",
  "exchangeRate": 0.00050,
  "fromAmount": "0.05",
  "toAmount": "100",
  "fee": "0.00", 
  "estimatedGas": "21000",
  "validUntil": "2023-08-16T12:00:00Z"
}
  • quoteId: A unique identifier for this quote. You'll need this if you decide to execute the transaction.

  • exchangeRate: The current exchange rate between the from token and USD.

  • fromAmount: The amount of the from token that will be sent.

  • toAmount: The amount in USD that will be received.

  • fee: These fees are varible based on your sub-payee takerate

  • estimatedGas: An estimate of the gas required for the transaction.

  • validUntil: The time until which this quote is valid.

4. Next Steps

Once you have the quote:

  1. Display the relevant information to your user.

  2. If the user agrees to the quote, you can proceed to execute the transaction using the quoteId.

  3. If the user wants to change something, you can request a new quote with updated parameters.

Common Issues and Troubleshooting

  • Invalid API Key: Make sure your API key is correct and active.

  • Unsupported Chain or Token: Check our documentation for supported chains and tokens.

  • Insufficient Balance: Ensure the fromAddress has enough balance for the transaction.

  • Rate Limiting: If you're making too many requests, you might hit our rate limits. Space out your requests if this happens.

Best Practices

  1. Always validate user input before sending it to the API.

  2. Handle API errors gracefully and provide meaningful feedback to your users.

  3. Consider implementing retry logic with exponential backoff for failed requests.

  4. Keep your API key secure and never expose it in client-side code.

By following this guide, you should be able to successfully request quotes for transactions using the bindpay API. If you encounter any issues or have questions, don't hesitate to reach out to our support team.

Last updated