Исправить скрипт для покупки токенов
Нашел такой скрипт, вставил свой кошелек и закрытый ключ к кошельку (mnemonic), но скрипт не работает, какая то ошибка.
const ethers = require('ethers');
const prompt = require('prompt-sync')({sigint: true});
const addresses = {
WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
router: "0x10ed43c718714eb63d5aa57b78b54704e256024e",
target: "0x8129686c77E63C22bE6a7F06F9C61f135BD0a0CF" // Change this to your address ELSE YOU GONNA SEND YOUR BEANS TO ME
}
const BNBAmount = ethers.utils.parseEther('0.1').toHexString();
const gasPrice = ethers.utils.parseUnits('10', 'gwei');
const gas = {
gasPrice: gasPrice,
gasLimit: 300000
}
const mnemonic = 'PUT YOUR MNEMONIC HERE';
const provider = new ethers.providers.WebSocketProvider('wss://bsc-ws-node.nariox.org:443');
const wallet = ethers.Wallet.fromMnemonic(mnemonic);
const account = wallet.connect(provider);
const router = new ethers.Contract(
addresses.router,
[
'function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)'
],
account
);
const snipe = async (token) => {
const tx = await router.swapExactETHForTokens(
0, // Degen ape don't give a fuxk about slippage
[addresses.WBNB, token],
addresses.target,
Math.floor(Date.now() / 1000) + 60 * 10, // 10 minutes from now
{
...gas,
value: BNBAmount
}
);
console.log(`Swapping BNB for tokens...`);
const receipt = await tx.wait();
console.log(`Transaction hash: ${receipt.transactionHash}`);
}
const token = prompt('Input token address:');
(async () => {
await snipe(token);
})();
Current freelance projects in the category Cryptocurrency & Blockchain
Need Smart Contract Engineer/Mentor
8000 USD
I want to find the Smart Contract Engineer/Mentor who has rich experience in Solidity smart contract development. Cryptocurrency & Blockchain, Engineering ∙ 5 days 7 hours back ∙ 11 proposals |