caelum0x 2b68bde5d5 Predikt: full Polymarket-style prediction market — web + mobile + on-chain + bots
Working tree is now the canonical repo. Off-chain play-money + trustless on-chain
(FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution,
mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 23:29:50 +03:00

156 lines
3.9 KiB
Markdown

# EIP712
Contract for EIP-712 typed structured data hashing and signing.
<b>Note, this implementation:</b>
- Uses `address(this)` for the `verifyingContract` field.
- Does NOT use the optional EIP-712 salt.
- Does NOT use any EIP-712 extensions.
This is for simplicity and to save gas.
If you need to customize, please fork / modify accordingly.
<!-- customintro:start --><!-- customintro:end -->
## Constants And Immutables
### _DOMAIN_TYPEHASH
```solidity
bytes32 internal constant _DOMAIN_TYPEHASH =
0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f
```
`keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")`.
### _DOMAIN_TYPEHASH_SANS_CHAIN_ID
```solidity
bytes32 internal constant _DOMAIN_TYPEHASH_SANS_CHAIN_ID =
0x91ab3d17e3a50a9d89e63fd30b92be7f5336b03b287bb946787a83a9d62a2766
```
`keccak256("EIP712Domain(string name,string version,address verifyingContract)")`.
This is only used in `_hashTypedDataSansChainId`.
### _DOMAIN_TYPEHASH_SANS_CHAIN_ID_AND_VERIFYING_CONTRACT
```solidity
bytes32 internal constant
_DOMAIN_TYPEHASH_SANS_CHAIN_ID_AND_VERIFYING_CONTRACT =
0xb03948446334eb9b2196d5eb166f69b9d49403eb4a12f36de8d3f9f3cb8e15c3
```
`keccak256("EIP712Domain(string name,string version)")`.
This is only used in `_hashTypedDataSansChainIdAndVerifyingContract`.
### _DOMAIN_TYPEHASH_SANS_VERIFYING_CONTRACT
```solidity
bytes32 internal constant _DOMAIN_TYPEHASH_SANS_VERIFYING_CONTRACT =
0xc2f8787176b8ac6bf7215b4adcc1e069bf4ab82d9ab1df05a57a91d425935b6e
```
`keccak256("EIP712Domain(string name,string version,uint256 chainId)")`.
This is only used in `_hashTypedDataSansVerifyingContract`.
## Hashing Operations
### _domainSeparator()
```solidity
function _domainSeparator()
internal
view
virtual
returns (bytes32 separator)
```
Returns the EIP-712 domain separator.
### _hashTypedData(bytes32)
```solidity
function _hashTypedData(bytes32 structHash)
internal
view
virtual
returns (bytes32 digest)
```
Returns the hash of the fully encoded EIP-712 message for this domain,
given `structHash`, as defined in
https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct.
The hash can be used together with `ECDSA-recover` to obtain the signer of a message:
```solidity
bytes32 digest = _hashTypedData(keccak256(abi.encode(
keccak256("Mail(address to,string contents)"),
mailTo,
keccak256(bytes(mailContents))
)));
address signer = ECDSA.recover(digest, signature);
```
### _hashTypedDataSansChainId(bytes32)
```solidity
function _hashTypedDataSansChainId(bytes32 structHash)
internal
view
virtual
returns (bytes32 digest)
```
Variant of `_hashTypedData` that excludes the chain ID.
Included for the niche use case of cross-chain workflows.
### _hashTypedDataSansChainIdAndVerifyingContract(bytes32)
```solidity
function _hashTypedDataSansChainIdAndVerifyingContract(bytes32 structHash)
internal
view
virtual
returns (bytes32 digest)
```
Variant of `_hashTypedData` that excludes the chain ID and verifying contract.
Included for the niche use case of cross-chain and multi-verifier workflows.
### _hashTypedDataSansVerifyingContract(bytes32)
```solidity
function _hashTypedDataSansVerifyingContract(bytes32 structHash)
internal
view
virtual
returns (bytes32 digest)
```
Variant of `_hashTypedData` that excludes the chain ID and verifying contract.
Included for the niche use case of multi-verifier workflows.
## EIP-5267 Operations
### eip712Domain()
```solidity
function eip712Domain()
public
view
virtual
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
```
See: https://eips.ethereum.org/EIPS/eip-5267