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
| Parameter | Type | Description |
|---|---|---|
requestId | Buffer | Unique request ID (UUID) |
signData | Buffer | Data to be signed |
dataType | DataType | Type of signing data |
chainId | number | Chain ID (optional) |
derivationPath | CryptoKeypath | Derivation path |
address | Buffer | Address for signing (optional) |
origin | string | Request source (optional) |
UR Example
UR:ETH-SIGN-REQUEST/ONADTPDAGDSWNNYAHGTOKPFPIAPANNROLNSAVYDTHHAOHDECAOWFLYLDLFAAUELPATAEGWSOLALPBAVYGUYTHNLFGMAYMWSGBYZOIYHTRDCFBANBFPBNDSPRJPNSDLGLBYIMJELTCNLNWZJLSEAEAELARTAXAAAACSLDAHTAADDYOEADLECSDWYKCSFNYKAEYKAEWKADWKAOCYTIZSYLCNSSDKGOCAExamples
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 displayLegacy 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