Skip to content

Commit 6d6822b

Browse files
committed
Add note on default_domain to README
1 parent 4db667d commit 6d6822b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ domain struct's definition leaves out the parameter entirely.
7171
The full signature: <br/>
7272
`make_domain(name: string, version: string, chainId: uint256, verifyingContract: address, salt: bytes32)`
7373

74+
##### Setting a default domain
75+
Constantly providing the same domain can be cumbersome. You can optionally set a default, and then forget it.
76+
It is automatically used by `.to_message()` and `.signable_bytes()`
77+
78+
```python
79+
import eip712_structs
80+
81+
foo = SomeStruct()
82+
83+
my_domain = eip712_structs.make_domain(name='hello world')
84+
eip712_structs.default_domain = my_domain
85+
86+
assert foo.to_message() == foo.to_message(my_domain)
87+
assert foo.signable_bytes() == foo.signable_bytes(my_domain)
88+
```
7489

7590
## Member Types
7691

0 commit comments

Comments
 (0)