@siacentral/ledgerjs-sia
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Sia Ledger

Ledger hardware wallet Sia bindings

Package Install

npm i @siacentral/ledgerjs-sia

Static Install

Static javascript builds are available on the releases page.

Package Usage

import Sia from '@siacentral/ledgerjs-sia';
import TransportWebHID from '@ledgerhq/hw-transport-webhid';

/**
 * connect connects to the plugged in Ledger using the WebHID transport
 * and returns the first Sia address of the ledger wallet.
 */
async function connect() {
	let sia;
	try {
		const transport = await TransportWebHID.create();
		sia = new Sia(transport);
		
		const address = await sia.getAddress(0);
		console.log(address);
	} catch (ex) {
		// TODO: handle error
	} finally {
		// always close the transport when done.
		if (sia) sia.close();
	}
}

connect();

Static Usage

<script type="text/javascript" src="/js/sia.js"></script>
<script type="text/javscript">
/**
 * connect connects to the plugged in Ledger using the WebHID transport
 * and returns the first Sia address of the ledger wallet.
 */
async function connect() {
	try {
		const transport = await TransportWebHID.create(),
			sia = new Sia(transport),
			address = await sia.getAddress(0);

		console.log(address);
	} catch (ex) {
		// TODO: handle error
	}
}

connect();
</script>

Package Sidebar

Install

npm i @siacentral/ledgerjs-sia

Weekly Downloads

31

Version

1.1.1

License

MIT

Unpacked Size

25.6 kB

Total Files

7

Last publish

Collaborators

  • rezant