current position:Home>Uniswap v2router calls addliquidity always restore

Uniswap v2router calls addliquidity always restore

2022-02-04 00:06:00 Q & A of Denglian community

/** *  Connect test chain  */let Web3 = require('web3');// var web3 = new Web3(Web3.givenProvider || "ws://localhost:8545");//  Connect to  ropsten  Test node var web3 = new Web3();web3.setProvider(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/6228221f6f894b5684e1b91bba538902"))let fs = require('fs')let source = fs.readFileSync('/Users/zhangchaoyin/node/ethereum/truffle_study/study_02/uniswap-periphery/build/contracts/UniswapV2Router02.json')let {  abi} = JSON.parse(source)let liamTokenAddress = '0x39A8A93ab5fEbE3c9fb152A10025b8f3Ea5864fa'let hangSonTokenAddress = '0x526981A02308cAa5f77a97e2fD314085b64B2d30'let from = '0xb8C3a29963f5EbB45c95873E8C448cEF5148A38f'let privKey =  "f3845b667c850652be0aebf73048ea58a887df984c7e1e4f0949268cd733b9a2";let uniswapV2Router02Address = '0xF404739DC4b65F02b0544E5CBe0790bcB9056f28'let {  sendSignedTransaction} = require('../utils/sendSignedTransaction')let addLiquidity = async () => {  let amountADesired = 10000000000  let amountBDesired = 1000000000  let amountAMin = 10000  let amountBMin = 1000  let block = await web3.eth.getBlock("latest");  let deadline = block.timestamp + 300;  console.log(deadline);  let uniswapV2Router02Storage = new web3.eth.Contract(abi, uniswapV2Router02Address)  let uniswapV2Router02StorageTx = await uniswapV2Router02Storage.methods.addLiquidity(liamTokenAddress, hangSonTokenAddress, amountADesired, amountBDesired, amountAMin, amountBMin, from, deadline)  await sendSignedTransaction(uniswapV2Router02StorageTx, from, uniswapV2Router02Address, privKey)};addLiquidity();

Whether other operations are required before calling , When the contract code is executed to createPair Always fail






Other answers 1:


Other answers 2:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202040005578650.html

Random recommended