Cross-Border Payment Protocol — OLIGHFT SMART COIN Visa Tier Smart Contract
#![no_std] use soroban_sdk::{ contract, contractimpl, contracttype, Address, Env, Symbol, Vec, token, }; #[contracttype] pub struct PaymentReceipt { pub tx_id: u64, pub from: Address, pub to: Address, pub amount: i128, pub asset_in: Address, pub asset_out: Address, pub rate: i128, pub fee: i128, pub timestamp: u64, } #[contract] pub struct VisaPayment; #[contractimpl] impl VisaPayment { /// Send a cross-asset payment pub fn send_payment( env: Env, from: Address, to: Address, asset_in: Address, asset_out: Address, amount: i128, ) -> PaymentReceipt { from.require_auth(); // Debit sender in asset_in let client_in = token::Client::new(&env, &asset_in); client_in.transfer( &from, &env.current_contract_address(), &amount ); // Get oracle exchange rate let rate = Self::get_rate(env.clone(), asset_in.clone(), asset_out.clone()); let fee = amount * 10 / 10000; // 0.1% fee let net = amount - fee; let out_amount = net * rate / 10000000; // Credit receiver in asset_out let client_out = token::Client::new(&env, &asset_out); client_out.transfer( &env.current_contract_address(), &to, &out_amount ); // Emit receipt event let tx_id = env.ledger().sequence() as u64; env.events().publish( (Symbol::new(&env, "payment"),), &tx_id ); PaymentReceipt { tx_id, from, to, amount, asset_in, asset_out, rate, fee, timestamp: env.ledger().timestamp(), } } /// Batch multiple payments in one tx pub fn batch_pay( env: Env, from: Address, recipients: Vec<Address>, amounts: Vec<i128>, asset: Address, ) -> Vec<PaymentReceipt> { from.require_auth(); // ... batch payment logic Vec::new(&env) } /// Get exchange rate from oracle pub fn get_rate( env: Env, from: Address, to: Address ) -> i128 { // Oracle integration - TWAP price feed 10000000 // 1:1 default } /// Refund a payment within 24h pub fn refund( env: Env, admin: Address, tx_id: u64 ) { admin.require_auth(); /* ... */ } }
| Function | Description | Auth | Gas (XLM) |
|---|---|---|---|
| initialize | Set admin, fee rate, oracle address | Admin | ~0.015 |
| send_payment | Cross-asset payment with auto-conversion | Sender | ~0.012 |
| batch_pay | Send to multiple recipients in one tx | Sender | ~0.025 |
| get_rate | Query oracle exchange rate (read-only) | None | ~0.001 |
| refund | Reverse payment within 24h window | Admin | ~0.010 |
| set_fee | Update fee basis points | Admin | ~0.006 |
| get_receipt | Fetch payment receipt by tx_id | None | ~0.001 |
| withdraw_fees | Claim accumulated protocol fees | Admin | ~0.008 |
Pay in any Soroban token, receive in any other
GLOBALStellar consensus settles in ~5 seconds
FASTSend to hundreds of recipients in one tx
EFFICIENTTWAP price feeds for fair conversion
PRICEEvery payment produces a verifiable receipt
AUDITAdmin-reversible payments within window
SAFETYStake $100 to activate your Visa tier and earn $6 daily rewards. Choose your contract period:
When a user activates with $100, the fee is distributed across the 8-level upline binary tree:
| Generation | Role | Commission | Amount |
|---|---|---|---|
| — | Main Wallet (Platform) | — | $60 |
| Gen 1 | Direct Inviter | 10% | $10 |
| Gen 2 | Inviter’s Inviter | 6% | $6 |
| Gen 3 | Upline Level 3 | 4% | $4 |
| Gen 4 | Upline Level 4 | 4% | $4 |
| Gen 5 | Upline Level 5 | 4% | $4 |
| Gen 6 | Upline Level 6 | 4% | $4 |
| Gen 7 | Upline Level 7 | 4% | $4 |
| Gen 8 | Upline Level 8 | 4% | $4 |
| TOTAL | $100 | ||
#[contracttype] pub struct VisaStake { pub staker: Address, pub stake_amount: i128, // $100 activation pub daily_reward: i128, // $6 per day pub duration_days: u32, // 90 | 180 | 365 days pub service_fee: i128, // $40 platform fee pub sponsor: Address, // direct inviter (Gen 1) pub start_time: u64, pub claimed_days: u32, } // 8-generation binary tree commission rates (in $) const GEN_COMMISSIONS: [i128; 8] = [ 10_0000000, // Gen 1: $10 (direct inviter) 6_0000000, // Gen 2: $6 4_0000000, // Gen 3: $4 4_0000000, // Gen 4: $4 4_0000000, // Gen 5: $4 4_0000000, // Gen 6: $4 4_0000000, // Gen 7: $4 4_0000000, // Gen 8: $4 ]; // Total referral: $40 | Main wallet: $60 | Grand total: $100 #[contractimpl] impl VisaPayment { /// Activate Visa staking — $100 deposit + $40 service fee /// duration: 90 (3 mo) | 180 (6 mo) | 365 (1 yr) /// $100 split: $60 main wallet + $40 across 8-gen binary tree pub fn activate_stake( env: Env, staker: Address, sponsor: Address, duration: u32, ) { staker.require_auth(); assert!(duration == 90 || duration == 180 || duration == 365, "invalid period"); let token = get_payment_token(&env); let tok = token::Client::new(&env, &token); let activation = 100_0000000; // $100 let fee = 40_0000000; // $40 service fee // Transfer $100 + $40 fee from user to contract tok.transfer(&staker, &env.current_contract_address(), &(activation + fee)); // ── Distribute $100 activation across binary tree ── let main_wallet = get_main_wallet(&env); let mut remaining = activation; // $100 let mut current = sponsor.clone(); for gen in 0..8 { let commission = GEN_COMMISSIONS[gen]; if let Some(upline) = get_sponsor(&env, ¤t) { tok.transfer( &env.current_contract_address(), ¤t, &commission, ); remaining -= commission; current = upline; } else { // No upline — remaining goes to main wallet break; } } // Send remainder ($60 or more) to main wallet tok.transfer( &env.current_contract_address(), &main_wallet, &remaining, ); let stake = VisaStake { staker: staker.clone(), stake_amount: activation, daily_reward: 6_0000000, // $6/day duration_days: duration, service_fee: fee, sponsor: sponsor.clone(), start_time: env.ledger().timestamp(), claimed_days: 0, }; env.storage().persistent().set(&staker, &stake); } /// Claim accrued daily rewards pub fn claim_rewards(env: Env, staker: Address) -> i128 { staker.require_auth(); let mut stake: VisaStake = env.storage().persistent().get(&staker).unwrap(); let elapsed = (env.ledger().timestamp() - stake.start_time) / 86400; let claimable = elapsed.min(stake.duration_days as u64) as u32 - stake.claimed_days; let payout = (claimable as i128) * stake.daily_reward; stake.claimed_days += claimable; env.storage().persistent().set(&staker, &stake); // Transfer rewards to staker token::Client::new(&env, &get_payment_token(&env)) .transfer(&env.current_contract_address(), &staker, &payout); payout // 90d→$540 | 180d→$1,080 | 365d→$2,190 } }
| Function | Description | Auth | Cost |
|---|---|---|---|
| activate_stake | Deposit $100 + $40 fee, choose period (90/180/365 days) | User | $140 total |
| claim_rewards | Claim accrued $6/day rewards | User | ~0.01 XLM |
| get_sponsor | Get upline address for a given user | None | ~0.001 XLM |
#[test] fn test_send_payment() { let env = Env::default(); env.mock_all_auths(); let sender = Address::generate(&env); let receiver = Address::generate(&env); let client = VisaPaymentClient::new(&env, &env.register_contract(None, VisaPayment)); let receipt = client.send_payment( &sender, &receiver, &usdc, &xlm, &1000_0000000 ); assert!(receipt.tx_id > 0); assert_eq!(receipt.fee, 1_0000000); // 0.1% assert!(receipt.timestamp > 0); }
OLIGHFT SMART COIN Visa Payment Contract v2.1.0 • Stellar Testnet • Rust/WASM
Built with soroban-sdk 21.0.0 • April 2026