Payouts
API to convert stablecoins to fiat money.
What is a payout?
A payout is an operation that moves funds from the sender's wallet to the receiver's bank account.
The payout can only be executed if a quote was created previously, and you have 5 minutes to execute the payout before the quote expires.
Please review how BlindPay manages the stablecoins in the flow of funds explanation.
How to mint USDB?
USDB is a fake ERC20 stablecoin powered by BlindPay to simulate payouts on development
instances.
EVM Chains
You can mint infinite USDB, but you need to add Ether to your wallet, so please get some Ether from https://www.alchemy.com/faucets/base-sepolia.
Put your instance_id
on the following url https://app.blindpay.com/instances/<instance_id>/utilities/mint and mint USDB on Base Sepolia Testnet
.
Remember: we're using Base Sepolia Testnet
in all the examples below, so please double check you're doing everything on the correct network.
Stellar
You can also mint USDB on Stellar Testnet
.
If you don't have the USDB asset on your wallet, you can create a trustline by calling the following endpoint:
Put your address
on the following url https://api.blindpay.com/v1/blochain-wallets/{address}/create-asset-trustline.
Put your address
on the following url https://api.blindpay.com/v1/blochain-wallets/{address}/mint-usdb and mint USDB on Stellar Testnet
.
Remember that the address must be the same address that you used to create the blockchain wallet on the blockchain wallets section.
Approving tokens for being moved by BlindPay
If you're using Stellar we will cover the approval process on the next section.
All stablecoins supported by BlindPay are ERC20 tokens, so you need to call the approve
method on the token contract to allow BlindPay to move the funds from any blockchain wallet.
Before approving the tokens, you need to have:
- A RPC provider URL from Base Sepolia Testnet
- A blockchain wallet with enough funds to execute the transaction
- The private key or any way to instantiate the blockchain wallet using ethers.js
- ERC20 token contract address (Provided by BlindPay on Quote API response)
- ERC20 ABI (Provided by BlindPay on Quote API response)
- BlindPay smart contract address (Provided by BlindPay on Quote API response)
To simulate an approval, we're going to use JavaScript to install express.js server and ethers.js library.
Before start, please ensure you have Node.js installed.
Now create a folder called approve-erc20
. Inside the folder, please run the following command:
And now install the dependencies:
Now create a file called index.js
inside it, paste the code below and replace the values with your own.
Now run you can run the code using the following command:
Now access http://localhost:3000 and after some seconds you should see a result like this in your browser:
Creating a payout on EVM chains
You can check the required fields in the BlindPay API Docs.
Before creating a payout, you need to:
- Create an account on BlindPay
- Create a development instance
- Create your API key
- Create a receiver
- Add a bank account
- Generate a quote
- Approve the tokens
Remember: replace YOUR_SECRET_TOKEN
with your API key, in_000000000000
with your instance ID, qu_000000000000
with the quote you generated previously and sender_wallet_address
with the same wallet address that you used to approve the tokens.
Creating a payout on Stellar
You can check the required fields in the BlindPay API Docs.
Remember: replace YOUR_SECRET_TOKEN
with your API key, in_000000000000
with your instance ID, qu_000000000000
with the quote you generated previously and sender_wallet_address
with the same wallet address that you used to approve the tokens.
Authorizing a token on Stellar
This endpoint will return a transaction hash that you can use to execute the payout.
With this hash we can create the transaction on Stellar.
First, you need to install the dependencies:
Now create a file called index.js
inside it, paste the code below and replace the values with your own.
::
Now run you can run the code using the following command:
Now you can create the payout on BlindPay using the hash that you got from the result.
Congratulations! You've completed your first payout using BlindPay. If you want to execute more payouts you need to create a new quote and approve the tokens again.
Testing scenarios
By default all the payouts are automatically completed in 'development' instances, but you can force 'refund' and 'failed' scenarios by adding specific values to the payout amount.
Amount | Result Status |
---|---|
666.00 | Failed |
777.00 | Refunded |