If I want to build a dapp that in future can extend for many chains that Moralis support.
Let says, I want to querry for the Allowance of a address. Should I use contract.methods.allowance provided by web3, Or I d better use Moralis API ?
How would you use Moralis API to get the allowance?
I would say that Moralis API is more generic by the fact that you can specify any blockchain in its request and in this way you can monitor multiple blockchains at the same time only by changing the parameters. By using the web3 what it will happen it would be that it would make a request to a speedy node in order to get that information.
It would be interesting to listen opinion from Moralis moderators on this…
It depends on your needs. Method
contract.methods.allowance needs active web3 Provider and Moralis Web3 API doesn’t. You can get onChain data without metamask and etc and allow your dapp users to get stats or data from all devices that have access to the Internet. You can show onchain data on your site even without the need for user authorization.
ok. What about the speed? Thru web3 provider should be faster right?
And, can a clouds function call Moralis API ?
You can get an access to Moralis Web3 API by simple http request. In cloud functions you need to use Moralis Cloud httpRequest
Moralis API is very fast in itself. Moralis can provide more information than a standard web3 provider.
I am having some problem with implement contract.methods.allowance on clouds function (clouds function recalled it self each time it comes to this line).
I trying to go around this by finding another way to get allowance (other than using
WEB3 = await Moralis.web3ByChain(…) )
Should I use Moralis Cloud httpRequest : or do you have any other suggestions? @Yomoo
Not sure why you want to call a web3 function from a cloud function.
Why should I NOT call a web3 function from a cloud function?
I was thinking that a cloud function runs on a Moralis Server and when you try to run a web3 function there it should have somehow access to a provider (speedy node).