Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getPair call via Ethers.Contract does not return a pair address #171

Open
Samboy76 opened this issue Sep 26, 2022 · 1 comment
Open

getPair call via Ethers.Contract does not return a pair address #171

Samboy76 opened this issue Sep 26, 2022 · 1 comment

Comments

@Samboy76
Copy link

Hi,

When I call following getPair under uniswapFactory contract I created via ethers.Contract in my javascript it doesn´t return any pair address.

const UniswapV2Factory = require("./build/contracts/IUniswapV2Factory.json");

uniswapFactory = new ethers.Contract(
		'0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f', // uniswap v2 factory address in Etherscan mainnet
		UniswapV2Factory.abi, wallet
	);

	const pairAddress = await uniswapFactory.getPair(wethAddress, otherAddress);
  	const pair = new Contract(pairAddress, UniswapV2Pair.abi, wallet);
	console.log("yeah2!");

Strange thing is if I removed await keywork it returns Promise { }.

However, if I run await uniswapFactory.getPair(wethAddress, otherAddress); directly under Truffle console it resolves the pair address correctly.

Any suggestions would be greatly appreciated as it´s been bugging me also for a very long time.

Thank you

@ghost
Copy link

ghost commented Dec 31, 2023

Depends on the wallet provider ( or an object ) that you are connecting with.

Make sure to check if the provider node could be connected, and using the right network.

Also, await keyword is essential since it resolves promise object ( since it is a remote call that uses node ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant