How to use Keplr's keplr_keystorechange event

Hello I am new to keplr wallet and am trying to use the event. So I created two accounts inside of keplr and can switch between them, and then event does run.

However when I switch between the two accounts the address shown under the account name on the main screen remains the same address. Why would that be?

Additionally once the event happens am I supposed to rerun the enable and getOfflineSigner functions, since they are technically different accounts? Anything else I need to do?

1 Like

Hi @jsoneaday

You only need to call keplrOfflineSigner.getAccounts() when the event occurs, then pass that wallet into the SecretNetworkClient you’re using to sign transactions or run queries.

Here’s a simple example

3 Likes

Yes you need to rerun enable() and getOfflineSigner()

1 Like

Thanks guys. And this is another thing that seems weird to me. Even after I change accounts. The address directly under the account name listed within the extension screen does not change. It’s the same address between account changes. Why is that?

Screenshot 2023-01-07 at 10.41.52 AM

I would recommend taking a look at griptape.js, a bootstrapping framework to get you started with keplr and secret network smart contracts on the front end. You’ll find some answers in there for how to use keplr events.

https://griptapejs.com/

I’m a front end developer for shade protocol, let me know if you have any questions!

2 Likes