Moralis.executeFunction from

import Web3 from "web3";

await Moralis.start({
  serverUrl: "YOUR_SERVER_URL",
  appId: "YOUR_APP_ID",
  web3Library: Web3,
});
// Get the initialized web3 instance from Web3.js
await Moralis.enableWeb3();
const web3 = Moralis.web3;

Where should i use Moralis.start? i am using MoralisProvider

If you’re using MoralisProvider there’s already Moralis.start inside to initialize so you don’t need to run Moralis.start anymore

I want to use Web3js instance instead of etherJs

1 Like

I have the same problem. We are using MoralisProvider. So we want to enable web3.js instead of ether.js using MoralisProvider. We couldnt find a solution for that. Can anyone help please? @cryptokid @YosephKS. Thanks.

can you give more info on the context?
maybe some code example
it is react, vanilla js, nodejs, something else?

I am trying to use Web3.js instead of Ether.js by following this solution Moralis JS-SDK v1.0.0 [beta] (Ethers.js support) and
react-moralisa githhub package

But I am using MoralisProvider from react-moralis package. I am not sure what I should do after this. I tried build but I am getting build errors. @cryptokid

function MyApp({Component, pageProps, router}) {

   const { initialize, isInitialized } = useMoralis()

   const initializeMoralis = () => {
       initialize({
           appId: moralisAppID,
           serverUrl: moralisServerUrl,
           web3Library: Web3,
         })
   }

   return (
       <>
       <MoralisProvider initializeOnMount={false} >
           <LayoutWrapper {...pageProps}>
               <Component {...pageProps} />
           </LayoutWrapper>
       </MoralisProvider>

       {initializeMoralis()}

       </>
       
       
   );
}

this seems to be a question of how to use web3 instead of ethers in react with MoralisProvider

what is Web3 in this line? what happens when you run the code that you pasted?

Why do you need web3 instead of ethers in react?

you can also init Moralis SDK as in vanilla js if needed in React (separately from using MoralisProvider)

Sorry for the late reply.

  1. Web3 is an instance from Web3.js package.
  2. We are running our solution in web3 and used widely in our project. So we are planning to stick with it for now.
  3. We are using Next.js application.

Is there a way we can make the whole project to use web3.js using react-moralis SDK? @cryptokid

You will need to use web3.js directly/separately. Moralis uses ethers.js now.

But i can set web3Library in Moarlis.Start(). So can I know or is there a format i can directly use Moralis.Start() in my Next.js app?

That uses ethers in new Moralis versions.

how can i convert a token amount to usd… Using ether, while calling the transferfrom method

You can fetch the token price and use the result for 1 unit of the token to calculate the expected amount

Thank you @qudusayo. I have an input box. where i input the amount tokens i want to send. my questions how do i convert that value that is being imputed to usd, using ethers.js

Using ethers, you’ll need to get it from some reserve, can’t tell much about that currently. A simple way I use is to get the token price and use the response to calculate what to do

How do i send signer.getbalance() from my smart contract
to moralis

What are you looking to do exactly? You can save this balance data to your Moralis server. You can also sync user addresses.

pls how do i use the moralis web3api. i have gotten the data from the user how do i send that data to moralis database.

You can save this data to your Moralis server. If you want to use the Web3API (this is a separate feature), you can check out the docs.

please someone should tell me a good rest api website that i can post my signer.getBalance to.