Cosmos Wallets
Dynamic offers full Cosmos support including Sei, Cosmos Hub, Axelar, Osmosis, Noble and more out of the box. You can also enable any custom Cosmos networks by following this guide.
Once your networks are anbled, and you’ve setup login via Cosmos, you’ll want to run operations using that wallet. This section will cover how to do that.
First we’ll type guard to check if the wallet is a Cosmos wallet, then we’ll create a Signing StargateClient, and finally we’ll use that to send a transaction.
Check if a wallet is a Cosmos wallet
The first thing you should do is check if the wallet is a Cosmos wallet. You can use the isCosmosWallet
helper method for that That way, TypeScript will know which methods etc. are available to you.
Fetch the wallet address
Normally you’d get the address using the wallet.address
property. However, bear in mind that this will only return the main Cosmos address, not the network addresses i.e. Noble, Axelar, etc.
To get the current Cosmos network address, use wallet.connector.getAddress()
which will return the address for the current network.
Create a Signing StargateClient
Now we’ll create a SigningStargateClient from cosmjs. This will allow us to do read and write operations on the chain.
Send a transaction
Now we’ll send a transaction using the client.