File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,35 @@ assert_eq!(encoded, my_data);
48
48
EIP-712:
49
49
50
50
``` rust,ignore
51
- todo!()
51
+ use alloy_dyn_abi::eip712::TypedData;
52
+ use alloy_sol_types::sol;
53
+
54
+ sol! {
55
+ struct Person {
56
+ string name;
57
+ address wallet;
58
+ }
59
+
60
+ struct Mail {
61
+ Person from;
62
+ Person to;
63
+ string contents;
64
+ }
65
+ }
66
+
67
+ let sender = Person {
68
+ name: "Cow".to_string(),
69
+ wallet: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826".parse().unwrap(),
70
+ };
71
+ let recipient = Person {
72
+ name: "Bob".to_string(),
73
+ wallet: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB".parse().unwrap(),
74
+ };
75
+ let mail = Mail { from: sender, to: recipient, contents: "Hello, Bob!".to_string() };
76
+
77
+ let typed_data = TypedData::from_struct(&mail, None);
78
+ let hash = typed_data.eip712_signing_hash().unwrap();
79
+ assert_eq!(hash, b256!("25c3d40a39e639a4d0b6e4d2ace5e1281e039c88494d97d8d08f99a6ea75d775"));
52
80
```
53
81
54
82
## How it works
You can’t perform that action at this time.
0 commit comments