This is an experience post #3579
Mengbuxiu
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
|
Hello @Mengbuxiu, Here https://book.getfoundry.sh/cast/ you can read about the Foundry Cast to learn more about the feature and how it works |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Im learning Foundry cast send/call, and I got an error, so I search the error by AI.
这是我的合约代码
这是测试参数传入
这是测试调用
最后返回了
0x
Ai gave me the answer: I requested a invalid contract address, and I fix it.
and other question appear
Why did I receive a success response when I requested an invalid contract address?
for example(The following is the correct implementation and verification, which is just an example)
The following is the answer given by AI. I think it is worth learning, so I share it here.
在以太坊中,交易成功(status=1)只表示交易被正确执行,没有回滚,但并不意味着目标合约的函数按预期工作。
🔍 具体原因分析(以你的案例为例)
🧩 你的案例还原
1.
执行 cast send 时:
2.
执行 cast call retrieve() 时:
✅ 正确验证方法
bashcast receipt <TRANSACTION_HASH> --rpc-url $RPC_URL
bash# 查看存储槽0(对应 myFavoriteNumber)
cast storage 0xe1Aa25618fA0c7A1CFDab5d6B456af611873b629 0 --rpc-url $RPC_URL
bashcast code 0xe1Aa25618fA0c7A1CFDab5d6B456af611873b629 --rpc-url $RPC_URL
📝 总结
通过严格检查地址输入和合约状态,你可以避免此类“看似成功实则无效”的问题!
Beta Was this translation helpful? Give feedback.
All reactions