GitHub, Ledger Devs Discord, Developer Portal
Ledger Hardware Wallet Stellar JavaScript bindings.
You may be using this package to communicate with the Stellar Nano App.
For a smooth and quick integration:
- See the developers’ documentation on the Developer Portal and
- Go on Discord to chat with developer support and the developer community.
All functions may throw an error, it's important to handle the errors properly.
We have written corresponding classes for exceptions that developers should actively handle, you can find them in the API section.
- StellarHashSigningNotEnabledError
- StellarDataParsingFailedError
- StellarUserRefusedError
- StellarDataTooLargeError
- Str
Error thrown when hash signing is not enabled on the device.
Error thrown when data parsing fails.
For example, when parsing the transaction fails, this error is thrown.
Error thrown when the user refuses the request on the device.
Error thrown when the data is too large to be processed by the device.
Stellar API
transport
Transport a transport for sending commands to a devicescrambleKey
a scramble key (optional, default"l0v"
)
import Str from "@ledgerhq/hw-app-str";
const str = new Str(transport)
Get Stellar application configuration.
str.getAppConfiguration().then(o => o.version)
Returns Promise<{version: string, hashSigningEnabled: boolean, maxDataSize: number?}> an object with the application configuration, including the version, whether hash signing is enabled, and the maximum data size in bytes that the device can sign.
Get Stellar raw public key for a given BIP 32 path.
path
string a path in BIP 32 formatdisplay
if true, the device will ask the user to confirm the address on the device, if false, it will return the raw public key directly (optional, defaultfalse
)
str.getPublicKey("44'/148'/0'").then(o => o.rawPublicKey)
Returns Promise<{rawPublicKey: Buffer}> an object with the raw ed25519 public key. If you want to convert it to string, you can use StrKey.encodeEd25519PublicKey
Sign a Stellar transaction.
path
string a path in BIP 32 formattransaction
Buffer signature base of the transaction to sign
str.signTransaction("44'/148'/0'", signatureBase).then(o => o.signature)
Returns Promise<{signature: Buffer}> an object with the signature
Sign a Stellar Soroban authorization.
path
string a path in BIP 32 formathashIdPreimage
Buffer the Soroban authorization hashIdPreimage to sign
str.signSorobanAuthorization("44'/148'/0'", hashIdPreimage).then(o => o.signature)
Returns Promise<{signature: Buffer}> an object with the signature
Sign a hash.
str.signHash("44'/148'/0'", hash).then(o => o.signature)
Returns Promise<{signature: Buffer}> an object with the signature