EIP712Signer
How to integrate EIP712Signer with ZKsync and ethers.js
This class provides support for an EIP712 transaction. The methods of this class are mostly used internally.
getDomain
Returns the EIP712 domain.
async getDomain(): Promise<ethers.TypedDataDomain>
sign
Signs an Ethereum transaction using EIP-712.
Inputs
Parameter | Type | Description |
---|---|---|
transaction | TransactionRequest | Transaction request. |
async sign(transaction: TransactionRequest): Promise<Signature>
getSignedDigest
Generates the signed digest of an Ethereum transaction using EIP-712.
Inputs
Parameter | Type | Description |
---|---|---|
transaction | TransactionRequest | Transaction request. |
static getSignedDigest(transaction: TransactionRequest): ethers.BytesLike
getSignInput
Generates the EIP-712 typed data from provided transaction. Optional fields are populated by zero values.
Inputs
Parameter | Type | Description |
---|---|---|
transaction | TransactionRequest | Transaction request. |
static getSignInput(transaction: TransactionRequest)
Example
const tx = EIP712Signer.getSignInput({
type: utils.EIP712_TX_TYPE,
to: "0xa61464658AfeAf65CccaaFD3a512b69A83B77618",
value: BigInt(7_000_000),
from: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049",
nonce: 0,
chainId: BigInt(270),
gasPrice: BigInt(250_000_000),
gasLimit: BigInt(21_000),
customData: {},
});