Converting funds in and out of wallets
Now that we've created our first wallet for an end-user, we want to add a crypto balance. To do this we will need fiat currency in our fiat wallets on the platform (details of the account numbers can be found in the BVNK portal) and, after ensuring there are funds available, we will use the Create quote endpoint to execute a trade.
curl --request POST \
--url https://api.sandbox.bvnk.com/api/v1/quote \
--header 'Accept: application/json' \
--header 'Authorization: Hawk id="B9jnE1U8eLblzHtNeJZRxfcq03CQKcmcP9FOrACMzXb1HfrxrePWsTfuP70JNns9", ts="1633010032", nonce="guGXrD", mac="uKeg+w1qXqzaF/8mOQGv8Y9IlRxyxTT+iINLe03EQ60="' \
--header 'Content-Type: application/json' \
--data '
{
"merchantId": "93403",
"from": "EUR",
"to": "ETH",
"payInMethod": "wallet",
"payOutMethod": "crypto",
"amountIn": 100,
"payOutInstruction": {
"code": "crypto",
"currency": "ETH",
"address": "0xEa61651823dEc1027565AFB908A0c5C06662cdBf"
}
}
'
Let's look at the inputs required to create a quote:
Parameter | Type | Description |
---|---|---|
merchantId | string | Your Merchant ID. You can find it on the Merchant Details page in your account. See this guide for creating one |
from | string | The originating currency you are holding on platform and will be trading from. |
to | string | The end currency you are trading into. |
payInMethod | string | Set to wallet to ensure funds are moved on platform. |
payOutMethod | string | Set to crypto to ensure this crypto is sent on to your client based wallet, rather than just your own balance. |
amountIn | big decimal | The amount in originating currency you'd like to convert. |
payOutInstruction.code | string | Set to crypto. |
payOutInstruction.currency | string | The currency code of the crypto asset you're sending. (this must be the same as the to value. |
payOutInstruction.protocol | string | If you're sending an asset present on multiple protocols (like USDC) then you'll need to specify the protocol (e.g. ERC20 or TRC20 in the case of USDC) |
payOutInstruction.address | string | The crypto address of the wallet we created in the previous step for our customer. |
You'll receive a response from the API:
{
"id": 93403,
"from": "EUR",
"to": "ETH",
"amountIn": 100.000000000000000000,
"amountDue": 100.000000000000000000,
"amountOut": 0.008933300000000000,
"price": 3470.162202097800000000,
"quoteStatus": "PENDING",
"paymentStatus": "PENDING",
"acceptanceExpiryDate": 1640875693683,
"paymentExpiryDate": 1640876572459,
"paymentReceiptDate": null,
"payInLegs": [],
"payInMethod": {
"id": 5,
"code": "wallet",
"settlementCurrency": "EUR",
"requestedCurrency": null,
"estimatedExchangeRate": null,
"accountMethods": []
},
"payOutMethod": {
"id": 3,
"code": "wallet",
"currency": "ETH",
"accountMethods": [
{
"id": 161,
"display": null
}
]
},
"uuid": "379a66e4-d402-48f4-a2a9-d4735ef2c79f",
"payOutInstruction": null,
"payInInstruction": null,
"usePayInMethod": null,
"usePayOutMethod": null,
"fee": 0.310000000000000006,
"processingFee": 0E-18,
"type": "FIXED",
"netPrice": 3470.162202097800000000,
"grossPrice": 3470.162202097800000000,
"amountInGross": 31,
"amountInNet": 31.000000000000000000,
"fees": {
"percentage": {
"service": 0.0100,
"processing": 0.0000
},
"value": {
"service": 0.31,
"processing": 0
}
},
"dateCreated": 1640875673705,
"lastUpdated": 1640875673705
}
Next, you simply accept the quote with the Accept quote endpoint and the transaction will execute into the wallet you specified.
To withdraw fiat, you will need to log in to the BVNK portal and perform a withdrawal.
Updated 5 months ago