Trait ethers::core::types::transaction::eip712::Eip712[][src]

pub trait Eip712 {
    type Error: Error + Send + Sync + Debug;
    fn domain(&self) -> Result<EIP712Domain, Self::Error>;
fn type_hash() -> Result<[u8; 32], Self::Error>;
fn struct_hash(&self) -> Result<[u8; 32], Self::Error>; fn domain_separator(&self) -> Result<[u8; 32], Self::Error> { ... }
fn encode_eip712(&self) -> Result<[u8; 32], Self::Error> { ... } }
Expand description

The Eip712 trait provides helper methods for computing the typed data hash used in eth_signTypedData.

The ethers-rs derive_eip712 crate provides a derive macro to implement the trait for a given struct. See documentation for derive_eip712 for more information and example usage.

For those who wish to manually implement this trait, see: https://eips.ethereum.org/EIPS/eip-712

Any rust struct implementing Eip712 must also have a corresponding struct in the verifying ethereum contract that matches its signature.

Associated Types

User defined error type;

Required methods

Returns the current domain. The domain depends on the contract and unique domain for which the user is targeting. In the derive macro, these attributes are passed in as arguments to the macro. When manually deriving, the user will need to know the name of the domain, version of the contract, chain ID of where the contract lives and the address of the verifying contract.

This method is used for calculating the hash of the type signature of the struct. The field types of the struct must map to primitive ethereum types or custom types defined in the contract.

Hash of the struct, according to EIP-712 definition of hashStruct

Provided methods

Default implementation of the domain separator;

When using the derive macro, this is the primary method used for computing the final EIP-712 encoded payload. This method relies on the aforementioned methods for computing the final encoded payload.

Implementors