DEV Community

jack
jack

Posted on

Tutorial: Bridging Fiat and Crypto in Your dApp with On-Chain IBANs

As dApp developers, the biggest friction point is onboarding and offboarding users' fiat currency. We usually rely on centralized exchanges. Monerium provides a powerful alternative with its programmable e-money and on-chain IBANs. Let's explore how to use their SDK.

The Concept: On-Chain E-Money
Monerium issues regulated stablecoins like EURe. More importantly, they allow you to associate a blockchain address with a real IBAN. Your backend application node can use their SDK to trigger transactions that move seamlessly between the banking world and the blockchain.

Step 1: Set Up the Monerium SDK
First, you'd get credentials from Monerium and install their client SDK in your backend project.

bash
npm install @monerium/sdk
Step 2: A Conceptual "Pay Invoice" Function
Imagine your dApp needs to pay a real-world invoice from its treasury.

JavaScript
import { MoneriumClient, Chain, Network } from '@monerium/sdk';

// Initialize the client with your credentials
const client = new MoneriumClient();

async function payFiatInvoice(userAddress, invoice) {
// Get authenticated context for the user's on-chain profile
const authContext = await client.getAuthContext();
const profile = authContext.profiles[0].id;

// The payment order
const order = {
    amount: invoice.amount, // e.g., "150.00"
    currency: "EUR",
    counterpart: {
        identifier: {
            standard: "iban",
            iban: invoice.recipientIban // The real-world IBAN to pay
        },
        name: invoice.recipientName
    },
    memo: `Invoice #${invoice.id}`
};

try {
    // This SDK call triggers a transfer from the user's on-chain
    // e-money balance to the external bank account.
    const payment = await client.placeOrder(order);
    console.log(`Payment successful! Transaction ID: ${payment.id}`);
    // The underlying Monerium protocol handles the fiat settlement.
} catch (err) {
    console.error("Payment failed:", err);
}
Enter fullscreen mode Exit fullscreen mode

}
This is a game-changer. You are programmatically controlling real electronic money from your application, bridging the gap between your smart contract logic and the traditional financial system.

For the full SDK documentation and more advanced use cases, the official community documentation is the definitive Guide.

Top comments (0)