Recommended: JavaScript SDK with React Hooks
For new React apps, we recommend the JavaScript SDK with React Hooks (
@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.Check if a wallet is a Cosmos wallet
This is a React-only guide. The
isCosmosWallet helper is a TypeScript utility for web.React
Fetch the wallet address
Normally you’d get the address using thewallet.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.
You can get the Cosmos wallet address using the wallet.address property and the network address using wallet.connector.getAddress().
React
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. You can create a SigningStargateClient from cosmjs to perform read and write operations on the chain.React
Send a transaction
Now we’ll send a transaction using the client. You can send a transaction using the client.React