Skip to Content

EthSignRequest

The EthSignRequest class handles Ethereum signing requests.

Used to send a signing request to the device.

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
requestIdBufferUnique request ID (UUID)
signDataBufferData to be signed
dataTypeDataTypeType of signing data
chainIdnumberChain ID (optional)
derivationPathCryptoKeypathDerivation path
addressBufferAddress for signing (optional)
originstringRequest source (optional)

UR Example

UR:ETH-SIGN-REQUEST/ONADTPDAGDSWNNYAHGTOKPFPIAPANNROLNSAVYDTHHAOHDECAOWFLYLDLFAAUELPATAEGWSOLALPBAVYGUYTHNLFGMAYMWSGBYZOIYHTRDCFBANBFPBNDSPRJPNSDLGLBYIMJELTCNLNWZJLSEAEAELARTAXAAAACSLDAHTAADDYOEADLECSDWYKCSFNYKAEYKAEWKADWKAOCYTIZSYLCNSSDKGOCA

Examples

EIP-1559 Transaction

import { KeystoneEthereumSDK } from '@keystonehq/keystone-sdk'; const eth = new KeystoneEthereumSDK(); 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