Skip to main content

Eip712Domain

Struct Eip712Domain 

Source
pub struct Eip712Domain<'a> {
    pub name: &'a str,
    pub version: &'a str,
    pub chain_id: u64,
    pub verifying_contract: &'a [u8; 20],
}
Expand description

EIP-712 domain separator parameters.

Use Eip712Domain::separator to compute the 32-byte domain separator hash.

use chains_sdk::ethereum::Eip712Domain;

let contract_addr = [0xCC_u8; 20];
let domain = Eip712Domain {
    name: "MyDapp",
    version: "1",
    chain_id: 1,
    verifying_contract: &contract_addr,
};
let sep = domain.separator();

Fields§

§name: &'a str

Human-readable name of the signing domain (e.g., “Uniswap”).

§version: &'a str

Current major version of the signing domain (e.g., “1”).

§chain_id: u64

EIP-155 chain ID (1 = mainnet, 5 = goerli, etc.).

§verifying_contract: &'a [u8; 20]

Address of the contract that will verify the signature (20 bytes).

Implementations§

Source§

impl<'a> Eip712Domain<'a>

Source

pub fn type_hash() -> [u8; 32]

The EIP-712 domain type hash: keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")

Source

pub fn separator(&self) -> [u8; 32]

Compute the 32-byte domain separator.

keccak256(abi.encode(TYPE_HASH, keccak256(name), keccak256(version), chainId, verifyingContract))

Auto Trait Implementations§

§

impl<'a> Freeze for Eip712Domain<'a>

§

impl<'a> RefUnwindSafe for Eip712Domain<'a>

§

impl<'a> Send for Eip712Domain<'a>

§

impl<'a> Sync for Eip712Domain<'a>

§

impl<'a> Unpin for Eip712Domain<'a>

§

impl<'a> UnsafeUnpin for Eip712Domain<'a>

§

impl<'a> UnwindSafe for Eip712Domain<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.