Quick Start
Connect a device and sign an Ethereum transaction end-to-end.
info
Runs in Chromium browsers (Chrome, Edge, Brave, Opera). Firefox and Safari do not support WebHID / Web Bluetooth.
Integration flow
A typical integration runs top to bottom. The Handled by column says which side owns each step:
| # | Step | Description | Handled by |
|---|---|---|---|
| 0 | Import import dcent from 'dcent-web-connector' | Add the connector to your app. | App |
| 1 | Select transport setTransport() | Choose the transport method. | Connector |
| 2 | Connect device automatic | Connect to the device over the chosen transport. | Connector |
| 3 | Get address getAddress() | Read an address from the connected device. | Connector |
| 4 | Build transaction construct the payload | Build the transaction to send. | App |
| 5 | Sign sign() | Sign the transaction on the device. | Connector |
| 6 | Broadcast send to the network | Send the signed transaction to the network. | App |
Handled by Connector · Handled by your app
Steps 4 (build payload) and 6 (broadcast) are handled in your app.
1 · Select transport
Call once before the first device interaction. Omit it to let the user pick.
import dcent from 'dcent-web-connector'
dcent.setTransport('hid') // WebHID over USB. Use 'ble' for Bluetooth.
2 · Get an address
const res = await dcent.getAddress({
chainId: 'eip155:1/slip44:60',
keyPath: "m/44'/60'/0'/0/0",
})
const address = res.body.parameter.address // "0x6A5C…"
3 · Sign a transaction
const signed = await dcent.sign({
method: 'signTransaction',
chainId: 'eip155:1/slip44:60',
payload: {
keyPath: "m/44'/60'/0'/0/0",
transaction: {
type: 2,
to: '0x000000000000000000000000000000000000dEaD',
value: '0x2386f26fc10000', // 0.01 ETH (wei, hex)
gasLimit: '0x5208',
maxFeePerGas: '0x77359400',
maxPriorityFeePerGas: '0x3b9aca00',
nonce: '0x0',
data: '0x',
},
},
})
if (signed.header.status === 'success') {
const rawTx = signed.body.parameter.signature // RLP-encoded signed tx
// 4 · broadcast: provider.send('eth_sendRawTransaction', [rawTx])
}
warning
Always pair request + response. A successful sign returns body.parameter.signature; a failure returns body.error.code (a string — see the Error Codes page).
Handle the result
try {
const r = await dcent.sign({ /* … */ })
if (r.header.status === 'success') use(r.body.parameter)
else handleError(r.body.error.code) // 'user_cancel', 'param_error', …
} catch (e) {
// transport/validation errors throw before reaching the device
}
info
Stuck on the first call? Email contact@iotrust.kr with the chainId, the method, and the response you received.