Skip to content

How to make connection and get provider to call methods on JSON contract? #358

Answered by myhendry
myhendry asked this question in Q&A
Discussion options

You must be logged in to vote

I manage to get it to work. I simply remove those web3-modal line of codes

hope below code is useful to others. If there's any issues identified in my codes below, feel free to point out and I will amend for benefit of others if they are referencing this code. Thanks

const setNewGreeting = async (newMessage: string) => {
    try {
      setIsLoading(true);

      const signer = library.getSigner();
      const greeterContract = new ethers.Contract(
        Greeter.address,
        Greeter.abi,
        signer
      );

      const transaction = await greeterContract.setGreeting(newMessage);
      await transaction.wait();
      setGreeting(newMessage);

      setIsLoading(false);
    } cat…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by myhendry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant