Documentation Index
Fetch the complete documentation index at: https://docs.startale.com/llms.txt
Use this file to discover all available pages before exploring further.
The SDK provider extends an event emitter. Subscribe with provider.on(event, handler) and unsubscribe with provider.removeListener (or its alias provider.off).
connect
provider.on('connect', ({ chainId }: { chainId: string }) => {
// chainId is hex (e.g. "0x74c" for Soneium Mainnet)
})
Fired when the provider transitions to a connected state. With wagmi, useAccount() exposes the same signal through status.
disconnect
provider.on('disconnect', (error: ProviderRpcError) => {
// Provider lost connection (network drop, popup closed, user disconnected)
})
accountsChanged
provider.on('accountsChanged', (accounts: string[]) => {
if (accounts.length === 0) {
// Disconnected
} else {
// Connected as accounts[0]
}
})
Fired when the connected account changes, including when the user disconnects (empty array) or switches accounts in the popup.
chainChanged
provider.on('chainChanged', (chainId: string) => {
// chainId is hex
})
Fired after a successful wallet_switchEthereumChain or after the user changes the active chain in the popup.
Cleanup
Always remove listeners when your component or scope unmounts:
const onAccountsChanged = (accounts: string[]) => { /* ... */ }
provider.on('accountsChanged', onAccountsChanged)
// Later: both forms work; removeListener is the primary SDK method
provider.removeListener('accountsChanged', onAccountsChanged)
// provider.off('accountsChanged', onAccountsChanged) // alias for removeListener
If you use wagmi, the connector handles event subscription internally. Just consume useAccount(), useChainId(), and friends.