Code Examples
const ethers = require('ethers');
// Basic configuration
const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/');
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider); // use .env or hardware wallet
const VAULT_ADDRESS = '0x...'; // real Vault address (get from official site or BSCScan)
const USDT_ADDRESS = '0x55d398326f99059fF775485246999027B3197955';
// Minimal ABI (get complete from BSCScan)
const VAULT_ABI = [
'function deposit(uint256 amount, uint8 lockDays) external',
'function withdraw(uint256 positionId) external',
'function getUserPositions(address user) external view returns (tuple(uint256 id, uint256 amount, uint8 lockDays, uint256 startTime, uint256 endTime, uint256 rewards)[])',
'function getPendingRewards(uint256 positionId) external view returns (uint256)'
];
const vault = new ethers.Contract(VAULT_ADDRESS, VAULT_ABI, wallet);Example 1: Approve USDT and Deposit (100 USDT, 10 days)
Example 2: Check Positions and Pending Rewards
Example 3: Withdraw (Withdraw matured position)
Example 4: Claim Affiliate Commissions (if available)
Usage Tips
Last updated
