1

Trying to do a contract interaction, rainbowkit/metamask is connected to my local host rpc from hardhat, I am having problems completing a transaction... Am I doing something wrong here? Metamask states transaction completed, but hardhat node shows the below error:

Code useContractWrite

export default function CreateProfile() {
  const chainId = 31337;
  const {
    config,
    error: prepareError,
    isError: isPrepareError,
  } = usePrepareContractWrite({
    addressOrName: contractAddresses[chainId][0],
    chainId: 31337,
    contractInterface: abiFile,
    functionName: "createProfile",
    args: ["string1", "string2", "string3", "string4"],
  });
  const { data, error, isError, write } = useContractWrite(config);

  const { isLoading, isSuccess } = useWaitForTransaction({
    hash: data?.hash,
  });

  return (
    <div>
      <button disabled={!write || isLoading} onClick={() => write()}>
        {isLoading ? "Creating..." : "Profile"}
      </button>
      {isSuccess && (
        <div>
          Successfully created your profile!
          <div>
            <a href={`https://etherscan.io/tx/${data?.hash}`}>Etherscan</a>
          </div>
        </div>
      )}
      {(isPrepareError || isError) && (
        <div>Error: {(prepareError || error)?.message}</div>
      )}
    </div>
  );
}

Error Recieved:

eth_call
  Contract call:       ProfileBuild#<unrecognized-selector>
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x610178da211fef7d417bc0e6fed39f05609ad788

  Error: Transaction reverted: function selector was not recognized and there's no fallback function........

eth_blockNumber
eth_feeHistory
eth_getTransactionCount
eth_feeHistory
eth_call
  WARNING: Calling an account which is not a contract
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x44691b39d1a75dc4e0a0346cbb15e310e6ed1e86

eth_sendRawTransaction
  Contract call:       ProfileBuild#createProfile
  Transaction:         0x7be4972d79273927a9a706c3f7466030c315b6c3a2480ea41fc0468f39bada15
  From:                0x8626f6940e2eb28930efb4cef49b2d1f2c9c1199
  To:                  0x610178da211fef7d417bc0e6fed39f05609ad788
  Value:               0 ETH
  Gas used:            234430 of 29025176
  Block #12:           0x5f70bd6b3e9349a68b03799ab896cebb1fc6cfa551f0b7142f7437fded3a4834

eth_call
  Contract call:       ProfileBuild#<unrecognized-selector>
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x610178da211fef7d417bc0e6fed39f05609ad788

  Error: Transaction reverted: function selector was not recognized and there's no fallback function.......

I do not believe my contract or abi are configured incorrectly, because I use the same config on another hook useContractRead() which works just fine My wallet is connecting and says the transaction was completed but the hardhat node shows the above error. The function exists as well. I am very confused. I have been successfully executing useContractRead() with the same abi, function, and contractaddress configuration. Thank you for any help

0

1 Answer 1

0

First of all, don't worry I was getting the same error during developing my NFT marketplace. NFT was listing properly and also indexing on the Moralis DB but the local node showing this error

As you are running the application at the local node, so might be due to some issue it's giving the error

You can try to stop the hardhat node, run again, reset metamask and then try it out... If still, it gives the error... ignore it and deploy the app on Goerli network (not on rinkeby as the merge is coming and rinkeby will be deprecated), make a transaction from the frontend side or whatever and then you will be all fine and running all trx properly

Look my project is running okay on testnet, but was giving issue on local:

👉 hardhat-nft-marketplace-next-js.vercel.app/

enter image description here

Cheers :)

3
  • Worked on test net! I think just funky hardhat node network stuff! Sep 9, 2022 at 2:59
  • Yup, hardhat was doing that stuff. Hardhat was running the Tx but also don't know also doing this stuff 👉👉 Who people find this answer helpful kindly upvote it, so that other persons can find help quickly Thanks Sep 11, 2022 at 6:45
  • dont have enough reputation to upvote but I tried, thank you for your response! Sep 12, 2022 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.