1import TrezorConnect from 'trezor-connect'
3const TREZOR_BASE_PATH = "m/44'/60'/0'/0/0"
5const formatChainId = val =>
6 typeof val === 'number'
8 : parseInt(val.slice(2), 16) // assume 0x-prefixed hex string
10const trezorSignTransaction = async (txn, hdpath) => {
11 const trezorFormattedTxn = {
12 to: txn.to.toString('hex'),
13 value: txn.value.toString('hex'),
14 data: txn.data.toString('hex'),
15 gasLimit: txn.gasLimit.toString('hex'),
16 gasPrice: txn.gasPrice.toString('hex'),
17 nonce: txn.nonce.length === 0 ? '00' : txn.nonce.toString('hex'),
18 chainId: formatChainId(txn.getChainId())
21 const sig = await TrezorConnect.ethereumSignTransaction({
23 transaction: trezorFormattedTxn
26 const payload = sig.payload
28 txn.v = Buffer.from(payload.v.slice(2), 'hex')
29 txn.r = Buffer.from(payload.r.slice(2), 'hex')
30 txn.s = Buffer.from(payload.s.slice(2), 'hex')
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