1import TrezorConnect from 'trezor-connect';
3const TREZOR_PATH = "m/44'/60'/0'/0/x";
5const formatChainId = val =>
6 typeof val === 'number' ? val : parseInt(val.slice(2), 16); // assume 0x-prefixed hex string
8const trezorSignTransaction = async (txn, hdpath) => {
9 const trezorFormattedTxn = {
10 to: txn.to.toString('hex'),
11 value: txn.value.toString('hex'),
12 data: txn.data.toString('hex'),
13 gasLimit: txn.gasLimit.toString('hex'),
14 gasPrice: txn.gasPrice.toString('hex'),
15 nonce: txn.nonce.length === 0 ? '00' : txn.nonce.toString('hex'),
16 chainId: formatChainId(txn.getChainId()),
19 const sig = await TrezorConnect.ethereumSignTransaction({
21 transaction: trezorFormattedTxn,
24 const payload = sig.payload;
26 txn.v = Buffer.from(payload.v.slice(2), 'hex');
27 txn.r = Buffer.from(payload.r.slice(2), 'hex');
28 txn.s = Buffer.from(payload.s.slice(2), 'hex');
33export { TREZOR_PATH, trezorSignTransaction };
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list