cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

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

Open dmiric opened this issue 3 years ago • 15 comments

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?

dmiric avatar Sep 23 '22 18:09 dmiric

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

LeTurt333 avatar Sep 24 '22 06:09 LeTurt333

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: @.***>

dmiric avatar Sep 24 '22 16:09 dmiric

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

pyramation avatar Sep 25 '22 22:09 pyramation

@pyramation Definitely going to check this out, thanks 🔥

LeTurt333 avatar Sep 27 '22 03:09 LeTurt333

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: @.***>

dmiric avatar Oct 11 '22 07:10 dmiric

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

pyramation avatar Oct 11 '22 07:10 pyramation

How can comosjs be used for kava?

heindrick17 avatar Nov 01 '22 17:11 heindrick17

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

pyramation avatar Nov 01 '22 19:11 pyramation

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?

heindrick17 avatar Nov 01 '22 20:11 heindrick17

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.

pyramation avatar Nov 01 '22 21:11 pyramation

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 avatar Nov 02 '22 01:11 heindrick17

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

heindrick17 avatar Nov 02 '22 04:11 heindrick17

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.

pyramation avatar Nov 02 '22 07:11 pyramation

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 avatar Nov 02 '22 07:11 heindrick17

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

heindrick17 avatar Nov 02 '22 10:11 heindrick17