I’m trying to find a query that will help me get the token addresses of the token pair from an LP address. Is this something I need to look for in web3.js?
Hey @markyjennings
Each LP contract has methods like : token0
and token1
. They will return you addresses of tokens in LP pair
You can use Web3 functionality in the Cloud Code (https://docs.moralis.io/cloud-functions-1#web3)
From the frontend https://docs.moralis.io/web3
Hope it will help you
Hello,
I’m working on a similar project.
Inside of the LP contract ABI, we can identify.
{
“constant”: false,
“inputs”: [
{
“internalType”: “address”,
“name”: “_token0”,
“type”: “address”
},
{
“internalType”: “address”,
“name”: “_token1”,
“type”: “address”
}
],
“name”: “initialize”,
“outputs”: [],
“payable”: false,
“stateMutability”: “nonpayable”,
“type”: “function”
}
But when I tried to view the contract.methods object.
const contract = new web3.eth.Contract(abi, address);
const value = contract.methods;
logger.info(value);
I’m not able to find
function name: “Initialize” Or
“token0” or “token1” in the object.
Any ideas where we can go from here?
what do you see there on that output? what happens if you add only that initialize function in that abi in const contract = new web3.eth.Contract(abi, address);
?
Thanks cryptokid! your question put me down the right path.
It made me realize I was using the generic ERC20 ABI that was inside of the Moralis documentation.
Once I updated the ABI, the appropriate methods then populated inside of the contract object.
From there you can call
contract.token0().call() and it returns the Token Address.
hey sir
how can i have the lptoken address from the token address?