Skip to main 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 (undemo-signed-payload encoded with RLP)
typedData = 2, // EIP-712 typed data (JSON string represented as bytes)
personalMessage = 3, // Signing a personal message
typedTransaction = 4, // Typed transaction flow (EIP-1559)
}

Inputs

FieldValue TypeMeaning
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 Demo

UR:ETH-SIGN-REQUEST/ONADTPDAGDSWNNYAHGTOKPFPIAPANNROLNSAVYDTHHAOHDECAOWFLYLDLFAAUELPATAEGWSOLALPBAVYGUYTHNLFGMAYMWSGBYZOIYHTRDCFBANBFPBNDSPRJPNSDLGLBYIMJELTCNLNWZJLSEAEAELARTAXAAAACSLDAHTAADDYOEADLECSDWYKCSFNYKAEYKAEWKADWKAOCYTIZSYLCNSSDKGOCA

Samples

EIP-1559 Transaction

import { KeystoneEthereumSDK } from "@keystonehq/keystone-sdk";

const eth = new KeystoneEthereumSDK();
const ur = eth.generateSignRequest({
requestId, // UUID string
signData: unsignedTxHex, // Hex string without 0x
dataType: 4, // typedTransaction value
path: "m/44'/60'/0'/0/0",
xfp: "12345678",
chainId: 1,
origin: "sample-client",
});
// Encode the UR into animated QR frames and display them

Legacy Transaction

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

EIP-712 TypedData

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

Personal Message

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

Next Step

After the device signs, decode the response using EthSignature.