EIP712Signer
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>
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: BigNumber.from(7_000_000),
from: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049",
nonce: 0,
chainId: BigNumber.from(270),
gasPrice: BigNumber.from(250_000_000),
gasLimit: BigNumber.from(21_000),
customData: {},
});
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
sign
Signs an Ethereum transaction using EIP-712.
Inputs
Parameter | Type | Description |
---|---|---|
transaction | TransactionRequest | Transaction request. |
async sign(transaction: TransactionRequest): Promise<Signature>