#Signing InvokeHostFunction operations with Ledger Nano S

1 messages · Page 1 of 1 (latest)

odd cape
#

Hello,

has anybody successfully created a smart contract using Ledger Nano S for signing the transaction object? I'm trying to create the contract from a dapp and when calling Ledger SDK's str.signTransaction to sign the transaction then instead of being asked to approve it on the ledger app I receive the error "Ledger device: UNKNOWN_ERROR (0xb005)".

A standard payment operation can be signed on the Ledger app successfully though, also signing the very same transaction with other wallets like Freighter or Albedo works fine as well. So maybe it's a limitation of the stellar ledger app or the ledger SDK.

import Transport from "@ledgerhq/hw-transport-webusb";
import Str from "@ledgerhq/hw-app-str";

const sorobanRpc = new SorobanRpc.Server('https://soroban-testnet.stellar.org');    

// get the first ledger account for signing
const transport = await Transport.create();
const str = new Str(transport);
const keyPath = "44'/148'/0'";
const key = await str.getPublicKey(keyPath);
const senderAddress = key.publicKey;
const account = await sorobanRpc.getAccount(senderAddress);

// hash of the already installed WASM code on TESTNET
const wasmHashHex = "7f7c3e89d2380f6e8e43eb418657436c491581cf2acbaa9ae4853a21c26bf859";
const wasmHash = hexToRawBytes(wasmHashHex);

// signing of this InvokeHostFunction operation fails later on the Ledger Nano app
const createCustomContractOp = Operation.createCustomContract({
  wasmHash: Buffer.from(wasmHash),
  address: Address.fromString(senderAddress),
  salt: crypto.getRandomValues(Buffer.alloc(32)),
});

// trx object for it
const createContractTrx: Transaction = new TransactionBuilder(account, {
      fee: BASE_FEE,
      networkPassphrase: Networks.TESTNET
    })
      .addOperation(createCustomContractOp)
      .setTimeout(30)
      .build();

let fails = await str.signTransaction(keyPath, createContractTrx.signatureBase());  // this fails with error "Ledger device: UNKNOWN_ERROR (0xb005)"
#

Here the payment operation which works successfully:

const paymentTrx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.TESTNET })
  .addOperation(Operation.payment({
      source: account.accountId(),
      destination: 'GC47QO37WB42X3L4KCRWUBFAIEK35JB5RE6KZABDROVV7UF6C2MN75XL',
      amount: '1',
      asset: Asset.native()
  }))
  .setTimeout(30)
  .build();

let works = await str.signTransaction(keyPath, paymentTrx.signatureBase());
console.log(works);
untold yoke
#

Ledger doesn't support soroban transactions

odd cape
#

What a pity! Thanks for the info.

odd cape
#

@untold yoke do you know by chance whether Trezor supports it? If yes I would try to migrate our dapp to it, but have no Trezor device yet to play around with it.

untold yoke
#

Trezor doesn't support it either, the Trezor team is really slow in adding support, a community member already proposed the update to their repo but they haven't added it (I don't expect them adding it this year)

odd cape
#

Thanks, important info for us, really appreciated. Then all my hope lies in the Ledger App team.

At least I've found a PR in their github repo preparing Soroban support, let's see when they will add it.

cedar warren
untold yoke
full gust
full gust
#

Fortunately, these RAM are sufficient for me to set up the Soroban domain. 🥹 @untold yoke

odd cape
#

I tried it today again with the newly released v5.0.3 from the Ledger Store, but unfortunately I still get error 0xb005 (SW_TX_PARSING_FAIL) upon calling str.signTransaction(). ☹️

full gust
#

Hi @odd cape, If it is for the purpose of development testing, you can install a version that supports Soroban through side-loading. https://github.com/lightsail-network/app-stellar/blob/develop/sideloading.md

We are also collaborating with the Ledger Team to be able to release it on Ledger Live, which will take some time.

GitHub

Stellar app for Ledger wallet. Contribute to lightsail-network/app-stellar development by creating an account on GitHub.

odd cape
#

Hi @full gust, thanks, it's not only for testing purposes thouhg. As we're already live with the product and just disabled ledger wallet integration until stellar app is able to sign our soroban transactions, so we need to wait until official stellar app supports it before offering ledger integraiton to our users.

gentle vapor
#

it says it was updated