为了进行契约交互,彩虹工具包/元a从hardhat连接到本地主机rpc,我在完成事务时遇到了问题.我在这里做错什么了吗?Metamask状态事务已完成,但hardhat节点显示以下错误:
代码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>
);
}收到的错误:
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.......我不相信我的合同或abi配置不正确,因为我在另一个钩子useContractRead()上使用了相同的配置,这个配置很好,我的钱包正在连接,并且说事务已经完成,但是硬顶帽节点显示了上面的错误。该函数也存在。我很困惑。我已经使用相同的abi、函数和契约地址配置成功地执行了useContractRead()。谢谢你的帮助
发布于 2022-09-06 18:58:38
首先,不要担心,我在开发NFT市场时也遇到了同样的错误。NFT正确地列出并在Moralis DB上进行索引,但是本地节点显示了此错误。
当您在本地节点上运行应用程序时,这可能是由于某些问题导致的错误
你可以试着阻止这个节点,再运行一次,重置元请求,然后再试一次……如果它仍然会给出错误..。忽略它,在Goerli网络上部署应用程序(而不是在rinkeby上,因为合并即将到来,rinkeby将被废弃),从前端或其他方面进行事务处理,这样您就可以正常运行所有的trx了。
听着,我的项目在testnet上运行得很好,但是在本地出现了问题:
硬帽子-nft-市场-next-js.vercel.app/

干杯:)
https://ethereum.stackexchange.com/questions/135108
复制相似问题