cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
654 stars 342 forks source link

Combine Tx data + Signature ( Generated using @cosmjs/ledger-amino) #1156

Open arunsybex opened 2 years ago

arunsybex commented 2 years ago

Frontend Signing component

import { LedgerConnector, LedgerSigner } from "@cosmjs/ledger-amino";
let transport = await TransportWebUSB.create();    
    const signer = new LedgerSigner(transport, {
      testModeAllowed: true,
      hdPaths: [stringToPath(this.path)],
      prefix: this.prefix
    });

    const [firstAccount] = await signer.getAccounts(); 
    let sig_doc : StdSignDoc = {"chain_id":"osmo-test-4","account_number":"253513","sequence":"0","fee":{"amount":[{"amount":"100","denom":"uosmo"}],"gas":"250"},"memo":"Some memo","msgs":[{"type":"cosmos-sdk/MsgSend","value":{"amount":[{"amount":"1000","denom":"uosmo"}],"from_address":"osmo1sr4jyvtk4kfwljywdnuzjurqlzlunsmvzadjq3","to_address":"osmo1z38jgyhkxx2wxzapm9c7hfryx0hh650h05m33h"}}]}

    let { signature, signed }  = await signer.signAmino(firstAccount.address, sig_doc)
    console.log(signature, signed);

Above signAmino giving Amino response but all LCD URLs not accepting Amino StdTx.

How to broadcast this?

webmaster128 commented 2 years ago

CosmJS does not support the LCD API anymore. You need to connect via Tendermint RPC for broadcasting.

0xharsha commented 1 year ago

@webmaster128 how to generate encoded transaction bytes from sign amino response? please share some source code.

kombos commented 1 year ago

I require the solution for this too? how to generate encoded transaction bytes from sign amino response and broadcast it?

liammcaweeney commented 1 year ago

I also am looking for a solution for this.

Wgil commented 3 months ago

+1