CCIP Integration / Tích hợp CCIP
English | Tiếng Việt
English
Overview
OlymPay integrates with Chainlink's Cross-Chain Interoperability Protocol (CCIP) to enable secure and reliable cross-chain transfers. This allows users to move assets seamlessly between different blockchain networks.
What is CCIP?
Chainlink CCIP is a secure cross-chain communication protocol that enables:
Cross-chain token transfers
Cross-chain smart contract calls
Programmable token transfers
Secure message passing
Key Features
Security: Leverages Chainlink's proven oracle infrastructure
Reliability: Battle-tested in production environments
Flexibility: Supports multiple blockchain networks
Cost-effective: Optimized gas usage and fees
Supported Networks
Ethereum
✅ Active
Full CCIP support
Avalanche
✅ Active
Full CCIP support
Base
✅ Active
Full CCIP support
BNB Chain
✅ Active
Full CCIP support
Solana
✅ Active
Full CCIP support
Olym3
✅ Active
Limit CCIP support
Integration
Basic Cross-Chain Transfer
import { CCIP } from '@olympay/sdk';
const ccip = new CCIP({
sourceChain: 'ethereum',
destinationChain: 'polygon'
});
// Create cross-chain transfer
const transfer = await ccip.createTransfer({
token: 'USDC',
amount: '100.00',
recipient: '0x...',
destinationChain: 'polygon'
});
// Execute transfer
const result = await transfer.execute();
Advanced Cross-Chain Operations
// Programmable token transfer
const programmableTransfer = await ccip.createProgrammableTransfer({
token: 'USDC',
amount: '100.00',
recipient: '0x...',
destinationChain: 'polygon',
instructions: {
action: 'swap',
targetToken: 'USDT',
slippage: '0.5%'
}
});
// Cross-chain smart contract call
const contractCall = await ccip.createContractCall({
contractAddress: '0x...',
functionName: 'mint',
parameters: ['0x...', '1000000000000000000'],
destinationChain: 'polygon'
});
API Endpoints
Create Cross-Chain Transfer
POST /ccip/transfer
Request Body:
{
"sourceChain": "ethereum",
"destinationChain": "polygon",
"token": "USDC",
"amount": "100.00",
"recipient": "0x...",
"gasLimit": "200000"
}
Get Transfer Status
GET /ccip/transfer/{transferId}/status
Response:
{
"success": true,
"data": {
"transferId": "0x...",
"status": "completed",
"sourceTxHash": "0x...",
"destinationTxHash": "0x...",
"timestamp": "2024-01-01T00:00:00Z"
}
}
Fees and Gas
CCIP Fees
Base Fee: $0.10 per transfer
Gas Fee: Varies by network
Premium Fee: Optional for faster processing
Gas Optimization
// Estimate gas for transfer
const gasEstimate = await ccip.estimateGas({
sourceChain: 'ethereum',
destinationChain: 'polygon',
token: 'USDC',
amount: '100.00'
});
// Optimize gas settings
const optimizedTransfer = await ccip.createTransfer({
token: 'USDC',
amount: '100.00',
recipient: '0x...',
destinationChain: 'polygon',
gasSettings: {
gasLimit: gasEstimate.gasLimit,
maxFeePerGas: gasEstimate.maxFeePerGas
}
});
Security Features
Multi-Signature: Multiple validator signatures required
Time Locks: Configurable time delays for large transfers
Rate Limiting: Protection against rapid transfers
Audit Trail: Complete transaction history
Error Handling
try {
const transfer = await ccip.createTransfer({
token: 'USDC',
amount: '100.00',
recipient: '0x...',
destinationChain: 'polygon'
});
const result = await transfer.execute();
} catch (error) {
if (error.code === 'INSUFFICIENT_BALANCE') {
console.log('Insufficient token balance');
} else if (error.code === 'NETWORK_ERROR') {
console.log('Network connection error');
} else {
console.log('Transfer failed:', error.message);
}
}
Best Practices
Always check balances before initiating transfers
Set appropriate gas limits to avoid failed transactions
Monitor transfer status for large amounts
Use time locks for high-value transfers
Test on testnets before mainnet deployment
Tiếng Việt
Tổng quan
OlymPay tích hợp với Giao thức Tương tác Chuỗi chéo (CCIP) của Chainlink để cho phép chuyển chuỗi chéo an toàn và đáng tin cậy. Điều này cho phép người dùng di chuyển tài sản liền mạch giữa các mạng blockchain khác nhau.
CCIP là gì?
Chainlink CCIP là một giao thức giao tiếp chuỗi chéo an toàn cho phép:
Chuyển token chuỗi chéo
Gọi hợp đồng thông minh chuỗi chéo
Chuyển token có thể lập trình
Truyền tin nhắn an toàn
Tính năng chính
Bảo mật: Tận dụng hạ tầng oracle đã được chứng minh của Chainlink
Đáng tin cậy: Đã được kiểm thử trong môi trường sản xuất
Linh hoạt: Hỗ trợ nhiều mạng blockchain
Tiết kiệm chi phí: Tối ưu hóa sử dụng gas và phí
Mạng được hỗ trợ
Ethereum
✅ Hoạt động
Hỗ trợ CCIP đầy đủ
Avalanche
✅ Hoạt động
Hỗ trợ CCIP đầy đủ
Base
✅ Hoạt động
Hỗ trợ CCIP đầy đủ
BNB Chain
✅ Hoạt động
Hỗ trợ CCIP đầy đủ
Solana
✅ Hoạt động
Hỗ trợ CCIP đầy đủ
Olym3
✅ Hoạt động
Hỗ trợ CCIP hạn chế
Tích hợp
Chuyển Chuỗi chéo Cơ bản
import { CCIP } from '@olympay/sdk';
const ccip = new CCIP({
sourceChain: 'ethereum',
destinationChain: 'polygon'
});
// Tạo chuyển chuỗi chéo
const transfer = await ccip.createTransfer({
token: 'USDC',
amount: '100.00',
recipient: '0x...',
destinationChain: 'polygon'
});
// Thực hiện chuyển
const result = await transfer.execute();
Hoạt động Chuỗi chéo Nâng cao
// Chuyển token có thể lập trình
const programmableTransfer = await ccip.createProgrammableTransfer({
token: 'USDC',
amount: '100.00',
recipient: '0x...',
destinationChain: 'polygon',
instructions: {
action: 'swap',
targetToken: 'USDT',
slippage: '0.5%'
}
});
// Gọi hợp đồng thông minh chuỗi chéo
const contractCall = await ccip.createContractCall({
contractAddress: '0x...',
functionName: 'mint',
parameters: ['0x...', '1000000000000000000'],
destinationChain: 'polygon'
});
Endpoints API
Tạo Chuyển Chuỗi chéo
POST /ccip/transfer
Nội dung yêu cầu:
{
"sourceChain": "ethereum",
"destinationChain": "polygon",
"token": "USDC",
"amount": "100.00",
"recipient": "0x...",
"gasLimit": "200000"
}
Lấy Trạng thái Chuyển
GET /ccip/transfer/{transferId}/status
Phản hồi:
{
"success": true,
"data": {
"transferId": "0x...",
"status": "completed",
"sourceTxHash": "0x...",
"destinationTxHash": "0x...",
"timestamp": "2024-01-01T00:00:00Z"
}
}
Phí và Gas
Phí CCIP
Phí cơ bản: $0.10 mỗi chuyển
Phí Gas: Khác nhau theo mạng
Phí cao cấp: Tùy chọn cho xử lý nhanh hơn
Tối ưu hóa Gas
// Ước tính gas cho chuyển
const gasEstimate = await ccip.estimateGas({
sourceChain: 'ethereum',
destinationChain: 'polygon',
token: 'USDC',
amount: '100.00'
});
// Tối ưu hóa cài đặt gas
const optimizedTransfer = await ccip.createTransfer({
token: 'USDC',
amount: '100.00',
recipient: '0x...',
destinationChain: 'polygon',
gasSettings: {
gasLimit: gasEstimate.gasLimit,
maxFeePerGas: gasEstimate.maxFeePerGas
}
});
Tính năng Bảo mật
Đa chữ ký: Yêu cầu nhiều chữ ký validator
Khóa thời gian: Độ trễ thời gian có thể cấu hình cho chuyển lớn
Giới hạn tốc độ: Bảo vệ chống chuyển nhanh
Dấu vết kiểm toán: Lịch sử giao dịch đầy đủ
Xử lý Lỗi
try {
const transfer = await ccip.createTransfer({
token: 'USDC',
amount: '100.00',
recipient: '0x...',
destinationChain: 'polygon'
});
const result = await transfer.execute();
} catch (error) {
if (error.code === 'INSUFFICIENT_BALANCE') {
console.log('Số dư token không đủ');
} else if (error.code === 'NETWORK_ERROR') {
console.log('Lỗi kết nối mạng');
} else {
console.log('Chuyển thất bại:', error.message);
}
}
Thực hành Tốt nhất
Luôn kiểm tra số dư trước khi bắt đầu chuyển
Đặt giới hạn gas phù hợp để tránh giao dịch thất bại
Giám sát trạng thái chuyển cho số tiền lớn
Sử dụng khóa thời gian cho chuyển giá trị cao
Kiểm thử trên testnet trước khi triển khai mainnet