Fetching bsc Token Price data

Hi all. New to Moralis and the forum - I was actually recommended the service on reddit when looking for some help with web3.js code

I’ve been trying to find an efficient way of fetching token prices for a list of token address that I have. I can currently do this in web3 using this example (https://gist.github.com/Linch1/ede03999f483f2b1d5fcac9e8b312f2c)

This works great for a single token and I guess I could expand this code to run a loop to iterate over a list of token address. I just wondered if Moralis could produce something similar?

Thanks

1 Like

Hey @ryan11
Welcome aboard :man_mechanic:

For stuff like this I recommend you using Cloud Functions.
If the list of tokens is large, using a loop is a bad idea. In this case, it is better to use web3 BatchRequest. This will speed up your code and will not overload Moralis nodes.

Happy BUIDLing :man_factory_worker:

P.S. There are plans to add inChain prices to Moralis.

1 Like

Hey @ryan11

We have added a functionality to fetch token prices on ETH, BSC and MATIC.

You can try it in the intereactive documenation https://admin.moralis.io/web3Api
image

Hey

Thanks, I saw this the other day but unfortunately the accuracy / decimal places is not good enough. eg for ZEP

I’m expecting something around 0.00000000405191 or similar

eg from bogged.finance (https://charts.bogged.finance/0x2E291e1c9f85a86d0C58Ae15621aaC005a8b2EAD)

or poocoin (https://poocoin.app/tokens/0x2e291e1c9f85a86d0c58ae15621aac005a8b2ead)

@Yomoo Do you know if the price accuracy can be improved on this ?

Hi @ryan11,

Please check out this post for more reference.

Thank you. :slight_smile: