Trait ethers_core::types::transaction::eip712::Eip712
source · pub trait Eip712 {
type Error: Error + Send + Sync + Debug;
// Required methods
fn domain(&self) -> Result<EIP712Domain, Self::Error>;
fn type_hash() -> Result<[u8; 32], Self::Error>;
fn struct_hash(&self) -> Result<[u8; 32], Self::Error>;
// Provided methods
fn domain_separator(&self) -> Result<[u8; 32], Self::Error> { ... }
fn encode_eip712(&self) -> Result<[u8; 32], Self::Error> { ... }
}
Expand description
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.
Required Associated Types§
Required Methods§
sourcefn domain(&self) -> Result<EIP712Domain, Self::Error>
fn domain(&self) -> Result<EIP712Domain, Self::Error>
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.