Skip to content

r0hansaxena/Remyra

Repository files navigation

Remyra

Cross-chain stablecoin remittance engine on Polkadot.

Send money globally with sub-1% fees, real-time FX conversion, and instant on-chain settlement — no banks, no intermediaries.


Overview

Remyra lets anyone send USDT or USDC to a recipient on the same chain or to any connected parachain via XCM, with the FX Oracle automatically converting the amount to the destination currency at the point of transfer.

Provider Fee Speed
Western Union 5.3% 3–5 days
MoneyGram 3.8% 2–3 days
Wise 1.2% 1–2 days
Remyra 0.30% Instant

Architecture

┌─────────────────────────────────────────────────────┐
│                    Frontend (Next.js)                │
│         MetaMask / EVM wallet  ←→  ethers.js v6      │
└──────────────────────┬──────────────────────────────┘
                       │
┌──────────────────────▼──────────────────────────────┐
│                  Remyra.sol                          │
│   sendRemittance()  /  sendCrossChainRemittance()    │
│          ↓ FX conversion        ↓ XCM dispatch       │
│       FXOracle.sol        XCM Precompile (0x…0803)   │
└─────────────────────────────────────────────────────┘
                       │ XCM
        ┌──────────────┼──────────────┐
     Moonbeam        Astar        Hydration  …

Smart Contracts

Contract Description
Remyra.sol Core remittance engine — handles token transfers, fee collection, XCM dispatch, and remittance history
FXOracle.sol FX rate oracle with 18-decimal precision; designed as the Solidity interface to a Rust PVM library in production
MockStablecoin.sol ERC-20 with faucet() for local/testnet use
interfaces/IXcmPrecompile.sol Interface for the Polkadot Asset Hub XCM precompile at 0x…0803

Supported Corridors

USD → INR, PHP, MXN, NGN, BRL, GBP, EUR, KES (and USDT ↔ USDC at 1:1)

Destination Chains

Polkadot Hub (same-chain), Moonbeam (2004), Astar (2006), Hydration (2034), Bifrost (2030)


Tech Stack

  • Contracts: Solidity 0.8.24, OpenZeppelin v5, Hardhat
  • Frontend: Next.js 14, React 18, ethers.js v6, TypeScript
  • Networks: Polkadot Asset Hub, Westend Asset Hub (testnet), Hardhat localhost

Getting Started

Prerequisites

  • Node.js ≥ 18
  • A .env file at the project root (see below)

Environment Variables

PRIVATE_KEY=0x...          # Deployer private key
WESTEND_RPC_URL=...        # Optional override for Westend RPC
POLKADOT_HUB_RPC_URL=...  # Optional override for Polkadot Hub RPC

Install

# Root (contracts + tooling)
npm install

# Frontend
cd frontend && npm install

Compile & Test

npm run compile
npm run test

Local Deployment

# Terminal 1 — start local node
npm run node

# Terminal 2 — deploy contracts
npm run deploy:local

After deployment, copy the printed contract addresses into frontend/src/constants/index.ts under CONTRACTS.

Run Frontend

cd frontend
npm run dev

Open http://localhost:3000 and connect MetaMask to localhost:8545 (Chain ID 31337).


Deploy to Testnet (Westend Asset Hub)

npm run deploy:westend

Make sure PRIVATE_KEY is set and the account has WND for gas. Update frontend/src/constants/index.ts with the new addresses and set DEFAULT_NETWORK = 'westend'.


How It Works

  1. Connect — user connects an EVM wallet to Polkadot Hub or Westend.
  2. Approve — the frontend requests an ERC-20 approve on the chosen stablecoin.
  3. SendsendRemittance (same-chain) or sendCrossChainRemittance (XCM) is called.
  4. ConvertFXOracle.convert() applies the FX rate and deducts the 0.30% fee.
  5. Settle — tokens land at the recipient address on the destination chain in the same block.

Contract API

Remyra.sol

// Estimate before sending
function estimateRemittance(address tokenIn, uint256 amount, string destCurrency)
    external view returns (uint256 amountOut, uint256 fee);

// Same-chain transfer
function sendRemittance(address tokenIn, uint256 amount, address recipient, string destCurrency)
    external returns (uint256 remittanceId);

// Cross-chain transfer via XCM
function sendCrossChainRemittance(address tokenIn, uint256 amount, address recipient, uint32 destChainId, string destCurrency)
    external returns (uint256 remittanceId);

// History
function getUserRemittances(address user) external view returns (uint256[] memory);
function getRemittance(uint256 id) external view returns (Remittance memory);
function getStats() external view returns (uint256 volume, uint256 fees, uint256 count, uint256 tokens);

FXOracle.sol

function getRate(string from, string to) external view returns (uint256 rate, uint256 updatedAt);
function convert(string from, string to, uint256 amountIn) external view returns (uint256 amountOut, uint256 fee);
function calculateFee(uint256 amount) external view returns (uint256 fee, uint256 feeBps);

PVM Track 2 Coverage

Category Implementation
PVM-experiments FXOracle.sol is the Solidity interface to a Rust FX library (compiled to PVM via RISC-V). Rust entry points: get_exchange_rate(), calculate_optimal_route()
Native Assets USDT and USDC handled as native Polkadot Asset Hub tokens via SafeERC20
Precompiles XCM precompile at 0x0000000000000000000000000000000000000803 used for cross-chain dispatch

Project Structure

Remyra/
├── contracts/
│   ├── Remyra.sol
│   ├── FXOracle.sol
│   ├── MockStablecoin.sol
│   └── interfaces/
│       └── IXcmPrecompile.sol
├── scripts/
│   └── deploy.ts
├── test/
│   └── Remyra.test.ts
├── frontend/
│   └── src/
│       ├── app/          # Next.js pages
│       ├── components/   # SendRemittance, Header
│       ├── hooks/        # useWallet
│       └── constants/    # ABIs, addresses, token/chain config
├── hardhat.config.ts
└── package.json

License

MIT

About

Cross-chain stablecoin remittance protocol built on Polkadot. Smart contract infrastructure for decentralized, borderless money transfers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors