The typical flow to process mint requests from your user
Using a user account's API key, you can process mint requests for the specified user. To do so, you can use the POST /api/transaction/mint-request endpoint. Here is an example implementation.
import { createSignature } from"./createSignature";constaxios=require('axios');constapiKey="{YOUR API KEY}";constsecret="{YOUR SECRET}";asyncfunctionmintRequest() {constpath="https://idrx.co/api/transaction/mint-request";constreq= {"toBeMinted":"51500","destinationWalletAddress":"0x8BD53F7fF88fD895D3686fe6369a07432822d30F","expiryPeriod":3600,// 1 hour"networkChainId":"137",// Polygon"requestType":"idrx",// 'idrx' or empty to receive IDRX, 'usdt' to receive USDT };constbufferReq=Buffer.from(JSON.stringify(req),'base64').toString('utf8');consttimestamp=Math.round((newDate()).getTime()).toString();constsig=createSignature('POST', path, bufferReq, timestamp, secret);constres=awaitaxios.post(path, req, { headers: {'Content-Type':'application/json','idrx-api-key': apiKey,'idrx-api-sig': sig, }, });console.log('res.data: ');console.log(res.data);}mintRequest();
After a successful request, you will get a response as follows:
Note that the amount returned is the amount after fees. The user can then do the payment through the payment page in the paymentUrl. To check the status of the transaction, you can use the Transaction History API. Here is an example code to do so: