argotorg / argotorg/solidity

Support EIP-712 typehash in `type`

Open
#14,157 24 comments 16 reactions 0 assignees View on GitHub
feature
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Abstract

Let's add support of `type(State).typehash` for structs, returning `bytes32` hashed stringed structure.

## Motivation

EIP-712 type hashes are pretty popular among smart contract of different companies. I believe it makes sense to support it on Solidity language layer.

## Specification

```solidity
bytes32 constant public STATE_TYPEHASH = keccak256(
"State("
"uint256 nonce,"
"uint256 totalSpent,"
"uint256 totalRefunded"
")"
);
```
=>
```solidity
struct State {
uint256 nonce;
uint256 totalSpent;
uint256 totalRefunded;
}

bytes32 constant public STATE_TYPEHASH = type(State).typehash;
```

## Backwards Compatibility

Not sure

Contributor guide

Open the contributing guide

Research direction

Start from the issue's EIP-712 example and review how the Solidity compiler represents struct types and compile-time type expressions. Determine the required semantics and compatibility implications for `type(State).typehash`; done means the specified expression compiles and returns the expected `bytes32` hash, with coverage for the relevant struct cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
blockchain, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.