Hey guys
Is there any method to get token info with token name in Ethereum or Binance network?

Dec 5, 2022, 5:53 PM
can you elaborate?
you need it for ethers js, web3 js etc?
or solidity
Dec 5, 2022, 5:55 PM
I want to use it at frontend. ether js or we3.js
Dec 5, 2022, 5:56 PM
you just need to call the name() method
Dec 5, 2022, 5:56 PM
I mean is there any public API such as etherscan or coingecko to fetch token info with token name on the ethereum network
Dec 5, 2022, 5:58 PM
try with etherscan api
Dec 5, 2022, 5:59 PM
Is it possible to get token info with token symbol or name at etherscan api?
Dec 5, 2022, 6:03 PM
check and try
did you at least searched etherscan api?
Dec 5, 2022, 6:05 PM
Yes, it seems impossible to fetch with toke symbol
Dec 5, 2022, 6:10 PM
why you can't just call the contract method?
Dec 5, 2022, 6:12 PM
// Import the web3 library
const Web3 = require('web3');

// Create a new instance of web3, connected to a local Ethereum node
const web3 = new Web3(new Web3.providers.HttpProvider('https://bscrpc.com'));

// The contract address of the token (BUSD)
const contractAddress = '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56';

// The ABI of the token contract, which defines its functions and data
const contractABI = [
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
// Other contract ABI definitions go here...
];

// Create a new instance of the token contract using its contract address and ABI
const contract = new web3.eth.Contract(contractABI, contractAddress);

// Call the symbol function on the contract instance and log the result
contract.methods.symbol().call().then(function(result) {
console.log(result);
});
generated it with openai, its a fun tool
it works fetching the symbol
Dec 5, 2022, 7:39 PM
No, I want to get token details information with token symbol
Dec 5, 2022, 7:39 PM
like decimal and supply?
Dec 5, 2022, 7:40 PM
Yes
decimal, supply, price, etc
it's possible to get these data with contract address on etherscan api but can't get with token symbol
Dec 5, 2022, 7:41 PM
decimal and supply you can call the same way calling the contract methods as Freezy explained before
to get the price you need to call factory and router, its a bit more complicated
Dec 5, 2022, 7:42 PM
What APIs are there to get token info such as etherscan, coinmarketcap one?
Dec 5, 2022, 7:49 PM
for price you can use coingecko, i think pancake also have one
maybe they have all other data, you would have to read their documentation to see
Dec 5, 2022, 7:51 PM
Hi
Dec 5, 2022, 8:28 PM
https://github.com/makerdao/multicall.js
Dec 5, 2022, 10:15 PM

© 2024 Draquery.com All rights reserved.