1.Lynex is a dex built on Linea Layer2, this is its contract site:
https://lineascan.build/address/0x610D2f07b7EdC67565160F587F37636194C34E74#readContract
2.Lynex official site, and related contract address is here:
https://lynex.gitbook.io/lynex-docs/security/contracts
My full code is here:
const ethers = require('ethers');
const Constants = {
WETH: ethers.utils.getAddress("0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f"),
ezEth: ethers.utils.getAddress("0x2416092f143378750bb29b79ed961ab195cceea5"),
router: "0x610D2f07b7EdC67565160F587F37636194C34E74",
myWallet: "0x7C09b8fE224591E797c533Bb74f0eF79077c3f9C", // Change this to your address
}
const EthAmount = ethers.utils.parseEther('0.0003'); //.toHexString();
//const gasPrice = ethers.utils.parseUnits('10', 'gwei');
const privateKey = "my_private_key"; // process.env.PRIVATE_KEY;
const provider = new ethers.providers.JsonRpcProvider('https://rpc.linea.build');
const account = new ethers.Wallet(privateKey,provider);
const lynexRouterAbi = require('../abi/lynexRouter.json');
const router = new ethers.Contract(Constants.router, lynexRouterAbi, account);
const snipe = async (token) => {
tokenA = Constants.WETH;
tokenB = Constants.ezEth;
// get wETH ca
var weth_ca = await router.wETH();
console.log("weth: ", weth_ca);
// get factory ca
var factory_ca = await router.factory();
console.log("factory_ca: ", factory_ca);
const tx = await router.swapExactETHForTokens(
0, // Degen ape don't give a fuxk about slippage
[tokenA, tokenB],
Constants.myWallet,
Math.floor(Date.now() / 1000) + 60 * 10, // 10 minutes from now
{from : account.address , value: EthAmount , gasLimit: 251234}
);
console.log(`Swapping wETH for tokens...`);
const receipt = await tx.wait();
console.log(`Transaction hash: ${receipt.transactionHash}`);
console.log("snipe done!");
}
(async () => {
await snipe();
})();
I just use node script.js, but got this error:
enter image description here