Closed vinodhum closed 1 year ago
Let's take keplr-extension
for example.
import { useWalletClient } from '@cosmos-kit/react';
export default function Home() {
const { client } = useWalletClient('keplr-extension');
useEffect(() => {
if (client) {
client.enable?.(['cosmoshub-4', 'osmosis-1', 'juno-1'])
client.getAccount?.('juno-4').then((account) => console.log(account))
client.getSimpleAccount?.('juno-4').then((account) => console.log(account))
client.getAccount?.('osmosis-1').then((account) => console.log(account))
client.getSimpleAccount?.('osmosis-1').then((account) => console.log(account))
client.getAccount?.('cosmoshub-4').then((account) => console.log(account))
client.getSimpleAccount?.('cosmoshub-4').then((account) => console.log(account))
}
})
...
}
@vinodhum Is this what you want to do ?
The best you can do for now
export default function Home() {
const { connect } = useChain('cosmoshub');
const { client } = useWalletClient();
useEffect(() => {
if (client) {
client.enable?.(['cosmoshub-4', 'osmosis-1', 'juno-1'])
client.getAccount?.('juno-4').then((account) => console.log(account))
client.getSimpleAccount?.('juno-4').then((account) => console.log(account))
client.getAccount?.('osmosis-1').then((account) => console.log(account))
client.getSimpleAccount?.('osmosis-1').then((account) => console.log(account))
client.getAccount?.('cosmoshub-4').then((account) => console.log(account))
client.getSimpleAccount?.('cosmoshub-4').then((account) => console.log(account))
}
})
return (
<div style={{ textAlign: 'center', margin: '4rem' }}>
<Button onClick={connect}>Connect</Button>
</div>
);
}
@vinodhum the wallet initializing issue has been solved, please upgade all the cosmos-kit deps to the latest v2 version
use the useChains
hook https://docs.cosmoskit.com/hooks/use-chains
Hi, How to connect multi chain at once and get their addresses. here is what I have tired based on chat on discord but looks like wallet is not getting initialized
mutli chain connect