We want to connect the people who have knowledge to the people who need it, to bring together people with different perspectives so they can understand each other better, and to empower everyone to share their knowledge.
const Web3 = require('web3'); const fs = require('fs'); let provider = new Web3.providers.HttpProvider("https://bsc-dataseed1.binance.org:443"); let web3 = new Web3(provider); let account = { address: 'address', privateKey: 'private key' }; let contractAddress = "0x10ED43C718714eb63d5aA57B78B54704E256024E"; // contract address not account address let abi = [abi]; console.log('load contract'); let contract = new web3.eth.Contract(abi, contractAddress); console.log('load contract done'); async function swapBNBToBUSD() { const nowInSeconds = Math.floor(Date.now() / 1000) const deadline = nowInSeconds + 900; const swapBNBToBUSDCall = contract.methods.swapExactETHForTokens( 1, ['0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56'], 'address nhận busd', deadline ); const swapBNBToBUSDTransaction = await web3.eth.accounts.signTransaction( { to: contractAddress, data: swapBNBToBUSDCall.encodeABI(), gas: 5500000, value: 10178 }, account.privateKey ); web3.eth.sendSignedTransaction(swapBNBToBUSDTransaction.rawTransaction).then(console.log); }; swapBNBToBUSD();
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Input your email to receive reset password link, or if you remember your password, you can click