Aller au contenu principal

Événements

Abonnez-vous aux événements après avoir sélectionné le provider.

Événements EIP-1193

ÉvénementProviderSignification
connectwindow.ethereumProvider connecté.
disconnectwindow.ethereumProvider déconnecté.
accountsChangedwindow.ethereumLa liste de comptes EVM a changé.
chainChangedwindow.ethereumLa chaîne EVM a changé.
messagewindow.ethereumMessage du provider.

Notifications du portefeuille Pali

ÉvénementSignification
pali_accountsChangedLe compte connecté a changé.
pali_chainChangedLa chaîne active a changé.
pali_unlockStateChangedL'état de verrouillage du portefeuille a changé.
pali_isBitcoinBasedL'état de la famille UTXO active a changé.
pali_xpubChangedLe xpub UTXO connecté a changé.
pali_blockExplorerChangedL'explorer de blocs actif a changé.
walletUpdateNotification de mise à jour de l'état du portefeuille.

Exemple

window.ethereum.on('accountsChanged', (accounts) => {
setAccount(accounts[0] || null);
});

window.ethereum.on('chainChanged', (chainId) => {
setChainId(chainId);
});

Supprimez les listeners lorsque votre composant est démonté afin d'éviter les mises à jour d'état dupliquées.