For developers

Under development

Mirage Card API (BETA)

The Mirage Card offers public API endpoints, allowing integration into your dApp or Wallet UI. You can also utilize our API to analyze your spending patterns: //api

Generating Signature

For each API method, a signature is required. Each method necessitates a distinct message. Here's a JavaScript example using Metamask to generate the signature.

if (window.bsc) {
    // Enable Metamask for BSC
    await window.bsc.request({ method: 'eth_requestAccounts' });
    const accounts = await window.bsc.request({ method: 'eth_accounts' });
    const address = accounts[0]; // Get the user's address
    const message = "Mirage Card: Sign In";
    const signature = await window.bsc.request({
        method: 'personal_sign',
        params: [message, address],
    });
}

Encryption Key

For Mirage to access encryption keys used in Top-Up transactions on the Binance Smart Chain (BSC) for querying transaction details, here's an example code to generate the encryption key.

const getTxEncryptionKey = async (txHash: string) => {
  if (window.bsc) {
    const txResult = await fetch(
      `https://api.bscscan.com/api?module=transaction&action=gettxinfo&txhash=${txHash}`
    ).then((response) => response.json());
    const msg = txResult?.result?.input;
    if (!msg) {
      return "";
    }
    const nonce = msg.slice(0, 32);
    // Generate encryption key using nonce
    const encryptionKey = Buffer.from(nonce, 'hex').toString('base64');
    return encryptionKey;
  }
  return "";
};

These code snippets illustrate using Metamask to handle signing and retrieving encryption keys for interacting with the Mirage Card API, specifically regarding encrypted transaction details on the Binance Smart Chain (BSC).

Last updated