Smart Contract Integration
This guide is for developers who want to integrate MakaPay at the smart contract level. Learn how to receive on-chain callbacks when payments are processed, enabling fully automated and trustless payment flows.
Overview
MakaPay V4 smart contracts provide:
CREATE2 Deterministic Addresses: Payment addresses are computed before deployment
On-Chain Callbacks: Your contract can receive notifications when payments arrive
Frontrun Protection: Fee amounts are baked into the address computation
Cross-Chain Recovery: Same address works on all EVM chains
┌─────────────────────────────────────────────────────────────────┐
│ Payment Flow (V4) │
│ │
│ 1. Compute Address ──→ 2. Customer Pays ──→ 3. Process Payment │
│ │ │
│ ▼ │
│ 4. Callback to Your │
│ Contract (optional)│
└─────────────────────────────────────────────────────────────────┘The onPaymentReceived Callback
The most powerful feature for developers is the optional callback that V4 contracts can trigger when a payment is processed. If your merchant address is a smart contract that implements the callback interface, it will be called automatically.
Interface
When Is It Called?
The callback is triggered when all of these conditions are met:
The payment is processed via
PaymentWalletFactoryV4.process()orprocessNoFee()The
merchantaddress has contract code (is a smart contract)The
callbackDataparameter is non-empty
Callback Data
The callbackData is arbitrary bytes that you define when creating the payment. This allows you to pass context to your contract, such as:
Order IDs
User identifiers
Product SKUs
Subscription IDs
Any custom data your application needs
Real-World Example: Gas Tank Deposits
MakaPay uses its own V4 callback system for the Gas Tank. Here's how the GasTankV4 contract receives deposit notifications:
How It Works
Payment Created: A deposit payment is created with
merchant = GasTank contract addressUser Sends USDT: User sends USDT to the computed payment address
Payment Processed: MakaPay calls
factory.process()with callback dataCallback Triggered: GasTank's
onPaymentReceived()is calledBalance Updated: User's Gas Tank balance is credited automatically
GasTank Implementation
Key Security Pattern
Notice how the GasTank verifies the caller:
This is critical. Since anyone can call your onPaymentReceived() function, you must verify that the caller is a legitimate payment wallet. The CREATE2 computation ensures only the correct wallet can produce a matching address.
Use Case Examples
1. Automated Subscription Service
2. NFT Minting on Payment
3. Escrow Release
4. DAO Treasury Deposits
CREATE2 Deterministic Addresses
How Address Computation Works
V4 uses CREATE2 to compute payment addresses before any contract is deployed:
Why This Matters
Pre-Computed: Address is known before deployment
Deterministic: Same inputs always produce same address
Frontrun Resistant: Fee amount is part of the salt (V4 upgrade)
Cross-Chain: Same address on all EVM chains
Computing Addresses Off-Chain
V4 Contract Reference
PaymentWalletFactoryV4
The main entry point for all payment operations.
computeAddress()
Pre-computes the payment wallet address.
process()
Processes a payment with the committed fee. Use for normal payments.
Parameters:
callbackData: If non-empty and merchant is a contract, triggersonPaymentReceived()
processNoFee()
Processes without taking fee. Use for:
Underpayments
Wrong token recovery
Gas Tank scenarios
getWalletStatus()
Check if a wallet exists and its balance.
PaymentWalletV4
Minimal proxy wallet that receives and forwards payments.
execute()
Called by factory only. Transfers funds and optionally triggers callback.
Security Considerations
1. Always Verify the Caller
Your onPaymentReceived() can be called by anyone. Always verify:
2. Handle Reentrancy
Use nonReentrant modifier if your callback updates state:
3. Validate Token Address
Don't blindly trust the token parameter:
4. Callback Failures Revert Everything
If your callback reverts, the entire payment transaction reverts. Make sure your callback logic is robust:
Integration Checklist
Before going live with smart contract integration:
Deployed Contract Addresses
MakaChain Mainnet (Chain ID: 777178)
PaymentWalletFactoryV4
0xCB45Df5057b9a287F9b95Af7ccdC49A1C9F2fcfA
PaymentWalletV4 Implementation
0x0e77A0A5845C49EbC8EEA521024b5a04F7B0E20B
GasTankV4
0xE94EB77a80BddD3a1c1813ed17894af0a3837d2C
USDT
0x30C28E393E0732335235685B345c95E6465Ad8A5
Other Chains
Factory and implementation addresses are identical across all supported chains (Ethereum, Polygon, BSC) due to CREATE2 deployment.
Need Help?
Technical Support: dev@makapay.io
Documentation: https://docs.makapay.io
GitHub: https://github.com/makapay
Last updated
