對indexed关键字的疑惑 #406
Unanswered
0xethanchen
asked this question in
Q&A
Replies: 2 comments 1 reply
-
这个描述当时也困扰了我,目前我了解到的是如果用 indexed 修饰的变量长度超出被保存为hash值的话,因为hash的单向性是无法获取原始值的,也就没有起到 indexed 用作检索的作用。 |
Beta Was this translation helpful? Give feedback.
1 reply
-
You can use this demo. // SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
contract aa {
struct S {
uint a;
uint b;
}
mapping(uint=>uint) public aa;
event a(S indexed s);
event b(mapping(uint=>uint) indexed aaa);
function f() public returns (S memory) {
emit a(S(1, 2));
aa[11]=22;
emit b(aa);
return S(1, 2);
}
} You will get this error.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
想請問
"indexed关键字可以修饰任意类型的变量"
這句話為什麼是錯誤的阿
我目前只知道超過固定長度的資料會被hash
不過這樣他還是可以用來修飾阿
還是有其他無法修飾的情況
想請問這個問題
Beta Was this translation helpful? Give feedback.
All reactions