Get the code
Clone the repository to follow along.
Bank
Deploys contracts, mints tokens, manages roles, and sets the FX rate for each payment
Sender
Initiates payments in the source currency (e.g., iEUR)
Receiver
Receives funds in the destination currency (e.g., iAUD)
- The Sender initiates a payment, specifying the receiver and amount in iEUR
- The Bank sets the conversion rate (how much iAUD the receiver gets)
- The Sender executes the payment — iEUR is burned from the sender and iAUD is minted to the receiver
Prerequisites
- Clone the cross-border-payments solution
- Create a Dfns organization if you don’t have one already, and note the organization id
- Create a service account for API access (see how to create one here)
- Create 3 wallets: Bank, Sender and Receiver on an EVM-compatible network (e.g.: Ethereum Sepolia)
- Fund the Bank and Sender wallets with Testnet ETH for gas fees (see using testnets)
- Make sure you have installed Node.js v18+
Project Structure
Configuration
Set up environment variables
Copy the example environment file and fill in your values:
.env
| Variable | Description |
|---|---|
DFNS_API_URL | Dfns API base URL (https://api.dfns.io) |
DFNS_ORG_ID | Your organization ID |
DFNS_AUTH_TOKEN | Service account auth token |
DFNS_CRED_ID | Credential ID for the signing key (found in Settings > Service Accounts) |
DFNS_PRIVATE_KEY | Private key for request signing (PEM format) |
BANK_WALLET_ID | Wallet ID for the bank/admin role |
SENDER_WALLET_ID | Wallet ID for the payment sender |
RECEIVER_WALLET_ID | Wallet ID for the payment receiver |
BLOCKCHAIN_RPC_URL | RPC endpoint for the target blockchain |
Deploy the System
- Deploys iEUR (source stablecoin)
- Deploys iAUD (destination stablecoin)
- Deploys the CrossBorderPayment contract
- Transfers iAUD ownership to the payment contract (so it can mint on settlement)
- Mints 1000 iEUR to the Sender wallet
End-to-End Payment Flow
Grant the MINTER_ROLE to the CrossBorderPayment contract
The payment contract needs permission to mint iAUD when settling payments:
Initiate a payment (Sender)
The sender initiates a 100 iEUR payment to the receiver. This approves the token transfer and calls Note the Payment ID from the output.
initPayment in one step:Set the FX rate (FX Provider)
The FX provider sets how much iAUD the receiver will get. For example, 150 iAUD for 100 iEUR (1.5x rate):
Execute the payment (Sender)
The sender confirms and executes the payment. This burns iEUR from the sender and mints iAUD to the receiver:
