<img src="https://user-images.githubusercontent.com/4631227/191834116-59cf590e-25cc-4956-ae5c-812ea464f324.png" height="100" />

## @ledgerhq/hw-transport-node-speculos-http

A transport for <https://github.com/LedgerHQ/speculos> Nano simulator using its HTTP API.

[GitHub](https://github.com/LedgerHQ/ledger-live/),
[Ledger Devs Discord](https://developers.ledger.com/discord-pro),
[Developer Portal](https://developers.ledger.com/)

### Getting started

*   Install <https://github.com/LedgerHQ/speculos>
*   Make sure to have a speculos running with an API port (default port is 5000).

```js
import SpeculosTransport from "@ledgerhq/hw-transport-node-speculos-http";

async function exampleSimple() {
  const transport = await SpeculosTransport.open();
  const res = await transport.send(0xE0, 0x01, 0x00, 0x00);
}

async function exampleAdvanced() {
  const transport = await SpeculosTransport.open({ baseURL: "http://localhost:5000" });
  transport.eventStream.once("data", {
    // we will click right when the display changes
    transport.button("right");
  });
  // we can also use eventStream.on and match the data buffer with the expected display before taking action
  // derivate btc address and ask for device verification
  const res = await transport.send(0xE0, 0x40, 0x01, 0x00, Buffer.from("058000002c8000000080000000000000000000000f"));
}
```

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

*   [SpeculosHttpTransport](#speculoshttptransport)
    *   [Parameters](#parameters)
    *   [Examples](#examples)
    *   [button](#button)
        *   [Parameters](#parameters-1)

### SpeculosHttpTransport

**Extends Transport**

Speculos TCP transport implementation

#### Parameters

*   `instance` **AxiosInstance**&#x20;
*   `opts` **SpeculosHttpTransportOpts**&#x20;

#### Examples

```javascript
import SpeculosHttpTransport from "@ledgerhq/hw-transport-node-speculos-http";
const transport = await SpeculosHttpTransport.open();
const res = await transport.send(0xE0, 0x01, 0, 0);
```

#### button

Press and release button
buttons available: left, right, both

##### Parameters

*   `but` **any**&#x20;

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<void>**&#x20;
