Skip to main content
Version: v2

Signing messages with Passport

Learn how to sign typed data messages using Immutable Passport in your Unreal game.

Overview

The ZkEvmSignTypedDataV4 method allows you to generate signatures for typed data objects using the EIP-712 standard. This is commonly used for:

  • Message verification
  • Off-chain authentication
  • Gasless transactions
  • Permit-style approvals

Prerequisites

📋Prerequisites
  • User must be logged into Passport
  • zkEVM provider must be initialised with ConnectEvm
  • User wallet must be connected with ZkEvmRequestAccounts

Implementation

Use the UImmutablePassport::ZkEvmSignTypedDataV4 method to sign EIP-712 structured messages.

Parameters

  • RequestJsonString: The EIP-712 structured data in JSON string format
  • ResponseDelegate: The response delegate to handle the callback

EIP-712 Standard

EIP-712 is a standard for hashing and signing typed structured data. It provides:

  • Domain separation: Prevents signature reuse across different dApps
  • Type safety: Ensures data integrity and structure
  • Human readability: Makes signatures more understandable to users

Example Typed Data Structure

{
"types": {
"EIP712Domain": [
{"name": "name", "type": "string"},
{"name": "version", "type": "string"},
{"name": "chainId", "type": "uint256"},
{"name": "verifyingContract", "type": "address"}
],
"Person": [
{"name": "name", "type": "string"},
{"name": "wallet", "type": "address"}
]
},
"primaryType": "Person",
"domain": {
"name": "Example App",
"version": "1",
"chainId": 13473,
"verifyingContract": "0x1234567890123456789012345678901234567890"
},
"message": {
"name": "John Doe",
"wallet": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"
}
}

Security Considerations

💡Security
  • Always validate the domain and verifying contract address
  • Ensure the typed data structure matches your application's expectations
  • Never sign data from untrusted sources
  • Implement proper error handling for failed signatures

Use Cases

Message Verification

Sign messages to prove identity or ownership without spending gas:

// Verify user ownership of an account
// Sign a challenge message
// Validate signature on your backend

Gasless Transactions

Enable meta-transactions by signing transaction data off-chain:

// User signs transaction parameters
// Relayer submits transaction on behalf of user
// No ETH required from user for gas

Permit Approvals

Sign token approvals without separate transaction:

// Sign permit for token spending
// Include signature with main transaction
// Saves gas and improves UX

Error Handling

Common errors and solutions:

  • User rejected signature: Handle gracefully, allow retry
  • Invalid typed data: Validate JSON structure before signing
  • Network errors: Implement retry logic with exponential backoff

Next Steps

After implementing typed data signing: