eip712

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const EIP712Domain = "EIP712Domain"

Variables

This section is empty.

Functions

func EncodeTypedDataV4

func EncodeTypedDataV4(ctx context.Context, payload *TypedData) (encoded ethtypes.HexBytes0xPrefix, err error)

func HashStruct

func HashStruct(ctx context.Context, typeName string, v interface{}, allTypes TypeSet) (result ethtypes.HexBytes0xPrefix, err error)

HashStruct allows hashing of an individual structure, without the EIP-712 domain

Types

type Type

type Type []*TypeMember

func (Type) Encode

func (t Type) Encode(name string) string

A type is encoded as:

> name ‖ "(" ‖ member₁ ‖ "," ‖ member₂ ‖ "," ‖ … ‖ memberₙ ")"

type TypeMember

type TypeMember struct {
	Name string
	Type string
}

func (*TypeMember) Encode

func (tm *TypeMember) Encode() string

An individual member is encoded as:

> type ‖ " " ‖ name

type TypeSet

type TypeSet map[string]Type

func ABItoTypedDataV4

func ABItoTypedDataV4(ctx context.Context, tc abi.TypeComponent) (primaryType string, typeSet TypeSet, err error)

Convert an ABI tuple definition, into the EIP-712 structure that's embedded into the "eth_signTypedData" signing request payload. It's a much simpler structure that flattens out a map of types (requiring each type to be named by a struct definition)

func (TypeSet) Encode

func (ts TypeSet) Encode(primaryType string) string

A map from type names to types is encoded per encodeType:

> If the struct type references other struct types (and these in turn reference even more struct types), > then the set of referenced struct types is collected, sorted by name and appended to the encoding.

type TypedData

type TypedData struct {
	Types       TypeSet                `ffstruct:"TypedData" json:"types"`
	PrimaryType string                 `ffstruct:"TypedData" json:"primaryType"`
	Domain      map[string]interface{} `ffstruct:"TypedData" json:"domain"`
	Message     map[string]interface{} `ffstruct:"TypedData" json:"message"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL