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
646 stars 331 forks source link

Can cosmjs be used to sign and broadcast transactions to chains like osmosis, kava, juno and others? #1274

Open dmiric opened 1 year ago

dmiric commented 1 year ago

Can cosmjs be used to sign and broadcast transactions to chains like osmosis, kava, juno and others? If yes can someone point me to an example of such a usage?

LeTurt333 commented 1 year ago

Yes!

Here is an example that includes building your own client

But you'll likely appreciate some of the tooling that abstracts away creating clients such as Cosmodal or Graz

Here is a great intro for how to use clients that also includes example usage of Cosmodal

And here is a tool that is very useful for interacting with smart contracts from a frontend

dmiric commented 1 year ago

Thank you

On Sat, 24 Sept 2022, 08:39 LeTurt, @.***> wrote:

Yes!

Here https://github.com/CosmosContracts/starter-kit/blob/main/pages/send.tsx#L59 is an example that includes building your own client

But you'll likely appreciate some of the tooling that abstracts away creating clients such as Cosmodal https://github.com/NoahSaso/cosmodal or Graz https://github.com/strangelove-ventures/graz

Here https://github.com/NoahSaso/cw-flash-ui-tutorial is a great intro for how to use clients that also includes example usage of Cosmodal

And here https://github.com/CosmWasm/ts-codegen is a tool that is very useful for interacting with smart contracts from a frontend

— Reply to this email directly, view it on GitHub https://github.com/cosmos/cosmjs/issues/1274#issuecomment-1256881581, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIS56GP656EPP4OYKZ7UILV72OYVANCNFSM6AAAAAAQUGGBMQ . You are receiving this because you authored the thread.Message ID: @.***>

pyramation commented 1 year ago

Hey @dmiric and @LeTurt333

For new chains, you may need to convert their proto files into the proper encoding. For this, you'll want to use Telescope

However, if you're using osmosis, juno, or stargaze, you can use these create-cosmos-app examples with pre-built libraries that already used Telescope, and also have everything ready to make transactions:

npm install -g create-cosmos-app

Osmosis

uses osmojs

cca --name myosmoapp --example --template osmosis

Juno

uses juno-network

cca --name myjunoapp --example --template juno

Stargaze

uses stargazejs

cca --name mystarsapp --example --template stargaze
LeTurt333 commented 1 year ago

@pyramation Definitely going to check this out, thanks 🔥

dmiric commented 1 year ago

I found the other way to do it. Now I'm only stuck on how to use evmos. My new method doesn't cover evmos for some reason. I haven't found a way to send evmos tokens using nodejs without keplr.

On Mon, 26 Sept 2022, 00:27 Dan Lynch, @.***> wrote:

Hey @dmiric https://github.com/dmiric and @LeTurt333 https://github.com/LeTurt333

For new chains, you may need to convert their proto files into the proper encoding. For this, you'll want to use Telescope https://github.com/osmosis-labs/telescope

However, if you're using osmosis, juno, or stargaze, you can use these create-cosmos-app https://github.com/cosmology-tech/create-cosmos-app examples with pre-built libraries that already used Telescope, and also have everything ready to make transactions:

npm install -g create-cosmos-app

Osmosis

https://user-images.githubusercontent.com/545047/184519024-2d34bf20-2440-4837-943f-4915a46409f5.svg

uses osmojs https://github.com/osmosis-labs/osmojs

cca --name myosmoapp --example --template osmosis

Juno

https://user-images.githubusercontent.com/545047/184516834-4b8190b0-0721-4778-b4fb-fa19ed3f9279.svg

uses juno-network https://github.com/CosmosContracts/typescript

cca --name myjunoapp --example --template juno

Stargaze

https://user-images.githubusercontent.com/545047/184694732-f4a3d397-14fb-415a-9562-a532f510f812.png

uses stargazejs https://github.com/cosmology-tech/stargaze-zone

cca --name mystarsapp --example --template stargaze

— Reply to this email directly, view it on GitHub https://github.com/cosmos/cosmjs/issues/1274#issuecomment-1257292540, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIS56AQVZB5DUWL6U4YRF3WADGWHANCNFSM6AAAAAAQUGGBMQ . You are receiving this because you were mentioned.Message ID: @.***>

pyramation commented 1 year ago

if you need evmos use evmosjs, cosmjs doesn't support EVM: https://github.com/evmos/evmosjs

heindrick17 commented 1 year ago

How can comosjs be used for kava?

pyramation commented 1 year ago

How can comosjs be used for kava?

Hey @heindrick17 You can use kavajs https://www.npmjs.com/package/kavajs If there are issues (I know they still need to update amino message names, but you should be able to use direct signer today) please make them here https://github.com/cosmology-tech/kavajs

heindrick17 commented 1 year ago

Thank you @pyramation However, when I try to test with kavajs, I am getting Error: Bad status on response: 501 on getSigningKavaClient function. I am using my RPC server url. Is my rpc server causing issue?

pyramation commented 1 year ago

Thank you @pyramation However, when I try to test with kavajs, I am getting Error: Bad status on response: 501 on getSigningKavaClient function. I am using my RPC server url. Is my rpc server causing issue?

means you are likely passing in a endpoint that is not RPC, or the RPC node is experiencing issues.

heindrick17 commented 1 year ago
Error: Bad status on response: 501

    at filterBadStatus (/Users/mac/Documents/lambda/node_modules/@cosmjs/tendermint-rpc/src/rpcclients/httpclient.ts:17:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HttpClient.execute (/Users/mac/Documents/lambda/node_modules/@cosmjs/tendermint-rpc/src/rpcclients/httpclient.ts:87:43)
    at async Function.detectVersion (/Users/mac/Documentslambda/node_modules/@cosmjs/tendermint-rpc/src/tendermint34/tendermint34client.ts:47:22)
    at async Function.create (/Users/mac/Documents/lambda/node_modules/@cosmjs/tendermint-rpc/src/tendermint34/tendermint34client.ts:41:22)
    at async Function.connectWithSigner (/Users/mac/Documents/lambda/node_modules/kavajs/node_modules/@cosmjs/stargate/src/signingstargateclient.ts:123:22)

This is full error log. Do you have any idea why? My RPC server is working and I am able to call apis to it.

heindrick17 commented 1 year ago

According to my check library code, it just make POST request to RPC server url. There isn't any implementation in root path(RPC server url itself), my RPC server response 501 Not Implemented error. Do you have any idea? @webmaster128 @pyramation

pyramation commented 1 year ago

According to my check library code, it just make POST request to RPC server url. There isn't any implementation in root path(RPC server url itself), my RPC server response 501 Not Implemented error. Do you have any idea? @webmaster128 @pyramation

Honestly, I would ask the Kava team, Kava discord, or somebody in the Kava dev community. Maybe kava is doing some non-cosmos-standard thing with their nodes that I'm unaware of.

heindrick17 commented 1 year ago

I don't think it is related to Kava. I have cosmos RPC server also, it doesn't have any implementation for root path. It will also response 501 error.

heindrick17 commented 1 year ago

Oh, I found issue. I was using REST API type RPC server. After I used tendermint RPC server, issue is gone, I can run code. Thank you. @pyramation