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