// when using "@ledgerhq/hw-transport-node-hid" library you need to go to// Settings -> Browser support in ledger stellar app and set this setting to 'No'importTransportfrom"@ledgerhq/hw-transport-node-hid";// import Transport from "@ledgerhq/hw-transport-u2f"; // for browserimportStrfrom"@ledgerhq/hw-app-str";importStellarSdkfrom"stellar-sdk";constgetStrAppVersion=async()=>{consttransport=awaitTransport.create();conststr=newStr(transport);constresult=awaitstr.getAppConfiguration();returnresult.version;}getStrAppVersion().then(v=>console.log(v));constgetStrPublicKey=async()=>{consttransport=awaitTransport.create();conststr=newStr(transport);constresult=awaitstr.getPublicKey("44'/148'/0'");returnresult.publicKey;};letpublicKey;getStrPublicKey().then(pk=>{console.log(pk);publicKey=pk;});constsignStrTransaction=async(publicKey)=>{consttransaction=newStellarSdk.TransactionBuilder({accountId: ()=>publicKey,sequenceNumber: ()=>'1234',incrementSequenceNumber: ()=>null}).addOperation(StellarSdk.Operation.createAccount({source: publicKey,destination: 'GBLYVYCCCRYTZTWTWGOMJYKEGQMTH2U3X4R4NUI7CUGIGEJEKYD5S5OJ',// SATIS5GR33FXKM7HVWZ2UQO33GM66TVORZUEF2HPUQ3J7K634CTOAWQ7startingBalance: '11.331',})).build();consttransport=awaitTransport.create();conststr=newStr(transport);constresult=awaitstr.signTransaction("44'/148'/0'",transaction.signatureBase());// add signature to transactionconstkeyPair=StellarSdk.Keypair.fromPublicKey(publicKey);consthint=keyPair.signatureHint();constdecorated=newStellarSdk.xdr.DecoratedSignature({hint: hint,signature: result.signature});transaction.signatures.push(decorated);returntransaction;}signStrTransaction(publicKey).then(transaction=>console.log(transaction.toEnvelope().toXDR().toString('base64')));