How to get ETH/Polygon/BSC Archive Node in Moralis Cloud Function?

Is there a way to get access to a Web3 element in a job to an archive node?

Moralis.web3ByChain(‘0x38’) doesn’t seem to be giving you that.

At the moment web3ByChain can’t give you archive nodes, we added it to the backlog of features to add.

You can still achieve it by finding the archive node URL you want from Speedy Nodes section.

Then initializing web3 in your cloud job with that URL (tutorial: https://www.youtube.com/watch?v=UJKSTSSXuPk&t=1s&ab_channel=MoralisWeb3)

So I tried that… but I get this error

Cloud Code tried to require ‘web3’ but this is not a whitelisted module

Don’t require it, it should be available without require

If I dont require it… I get that error:

Web3 is not defined

Found a workaround… do you think it is safe?

const web3 = Moralis.web3ByChain('0x38')
web3.setProvider('https://speedy-nodes-nyc.moralis.io/...../bsc/mainnet/archive')

It looks safe to me if it works.