Cross-Chain Calls
Execute smart contract functions across different blockchain networks using DI Gateway's secure cross-chain communication protocol.
Call Types
Simple Contract Call
Execute a function on a destination chain without token transfers:
await di.gateway.callContract({
destinationChainId: 56, // BSC
destinationContract: '0x742d35Cc6634C0532925a3b8D400E4C0C0b8C8e0',
payload: encodedFunctionCall,
gasToken: 'DUSD',
gasLimit: 200000
});Contract Call with Token Transfer
Send tokens along with the contract call:
await di.gateway.callContractWithToken({
destinationChainId: 137, // Polygon
destinationContract: '0x742d35Cc6634C0532925a3b8D400E4C0C0b8C8e0',
payload: encodedFunctionCall,
symbol: 'DUSD',
amount: ethers.parseEther('1000'),
gasToken: 'DUSD',
gasLimit: 300000
});Function Encoding
Basic Function Call
Complex Function Call
Execution Flow
Message Creation
Message Execution
Gas Management
Gas Estimation
Gas Token Options
Advanced Features
Batch Calls
Conditional Execution
Error Handling
Common Errors
Retry Mechanism
Monitoring & Tracking
Message Status
Event Monitoring
Best Practices
Security
Validate Inputs: Always validate function parameters
Access Control: Implement proper access controls on target contracts
Reentrancy Protection: Use reentrancy guards
Gas Limits: Set appropriate gas limits
Efficiency
Batch Operations: Group multiple calls when possible
Gas Optimization: Use efficient encoding
Minimal Data: Send only necessary data
Caching: Cache frequently used data
Reliability
Error Handling: Implement comprehensive error handling
Retry Logic: Add retry mechanisms for failed calls
Monitoring: Monitor call status and results
Fallback: Have fallback mechanisms for critical operations
Integration Examples
DeFi Protocol Integration
NFT Cross-Chain Transfer
Governance Cross-Chain Execution
Last updated