Hi,
How can I import my cloud functions in js file to self hosted server? The client does not see the functions in the main.js file under the cloud folder (outside of src) in the file structure. It only sees functions under main.ts. I cannot import the cloud.js file that I created under ‘self-generated’ folder into main.ts because there is no typescript. What is the solution?
const web3 = new Moralis.Web3(
new Moralis.Web3.providers.HttpProvider(“https://polygon-rpc.com”)
);
How can i create web3 instance like that above in cloud code in self hosted parse server?
All the cloud functions should be defined in the cloud code, however, if you want to define a function outside the cloud folder then you can define it as a normal function and then import that function to main.js and use it as a callback.
// from self-generated file
export const testFunction = async() => {
}
// import function in cloud code main.js
Moralis.Cloud.define("functionName", testFunction);
1 Like
you can also create web3 instance by using web3js or etherjs packages.