Skip to Content

EthSignRequest

The EthSignRequest class handles Ethereum signing requests.

Encodes signing data for the device to scan. It does not create or broadcast the transaction.

DataType Enum

enum DataType { transaction = 1, // Legacy transaction (RLP encoded unsigned data) typedData = 2, // EIP-712 typed data (JSON string as bytes) personalMessage = 3, // Personal message signing typedTransaction = 4 // Typed transaction (EIP-1559) }

Parameters

ParameterTypeDescription
requestIdBufferOptional constructor field: UUID bytes; the high-level helper below takes a UUID string
signDataBufferData to be signed
dataTypeDataTypeType of signing data
chainIdnumberChain ID (optional)
derivationPathCryptoKeypathDerivation path
addressBufferSigner address bytes (optional)
originstringRequest source (optional)

UR Example

UR:ETH-SIGN-REQUEST/ONADTPDAGDSWNNYAHGTOKPFPIAPANNROLNSAVYDTHHAOHDECAOWFLYLDLFAAUELPATAEGWSOLALPBAVYGUYTHNLFGMAYMWSGBYZOIYHTRDCFBANBFPBNDSPRJPNSDLGLBYIMJELTCNLNWZJLSEAEAELARTAXAAAACSLDAHTAADDYOEADLECSDWYKCSFNYKAEYKAEWKADWKAOCYTIZSYLCNSSDKGOCA

Examples

These examples use KeystoneEthereumSDK.generateSignRequest, which takes hex strings and a UUID string. Its parameter names differ from the registry constructor above. unsignedTxHex and unsignedLegacyHex are the unsigned signing bytes from your transaction library, without a 0x prefix. For EIP-1559, include the 02 type byte. typedDataJson must contain the complete EIP-712 object.

Use the actual path and master fingerprint exported by the device. Keep the request ID and original unsigned transaction until the response has been verified.

EIP-1559 Transaction

import { KeystoneEthereumSDK } from '@keystonehq/keystone-sdk'; const eth = new KeystoneEthereumSDK(); const requestId = globalThis.crypto.randomUUID(); const ur = eth.generateSignRequest({ requestId, // uuid string signData: unsignedTxHex, // hex without 0x dataType: 4, // typedTransaction path: "m/44'/60'/0'/0/0", xfp: '12345678', chainId: 1, origin: 'your-app', }); // Encode UR into animated QR frames and display

Legacy Transaction

const ur = eth.generateSignRequest({ requestId, signData: unsignedLegacyHex, dataType: 1, // transaction path: "m/44'/60'/0'/0/0", xfp: '12345678', chainId: 1, origin: 'your-app', });

EIP-712 TypedData

const dataHex = Buffer.from(typedDataJson, 'utf8').toString('hex'); const ur = eth.generateSignRequest({ requestId, signData: dataHex, dataType: 2, // typedData path: "m/44'/60'/0'/0/0", xfp: '12345678', origin: 'your-app', });

Personal Message

const dataHex = Buffer.from(message, 'utf8').toString('hex'); const ur = eth.generateSignRequest({ requestId, signData: dataHex, dataType: 3, // personalMessage path: "m/44'/60'/0'/0/0", xfp: '12345678', origin: 'your-app', });

Next Step

After the device signs, decode the response using EthSignature.

Last updated on