본문으로 건너뛰기

Event

provider를 선택한 뒤 event를 subscribe하세요.

EIP-1193 event

EventProvider의미
connectwindow.ethereumProvider가 connected 상태입니다.
disconnectwindow.ethereumProvider가 disconnected 상태입니다.
accountsChangedwindow.ethereumEVM account list가 변경되었습니다.
chainChangedwindow.ethereumEVM chain이 변경되었습니다.
messagewindow.ethereumProvider message입니다.

Pali wallet notification

Event의미
pali_accountsChangedConnected account가 변경되었습니다.
pali_chainChangedActive chain이 변경되었습니다.
pali_unlockStateChangedWallet lock state가 변경되었습니다.
pali_isBitcoinBasedActive UTXO family state가 변경되었습니다.
pali_xpubChangedConnected UTXO xpub이 변경되었습니다.
pali_blockExplorerChangedActive block explorer가 변경되었습니다.
walletUpdateWallet state update notification입니다.

예시

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

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

component가 unmount될 때 listener를 제거하여 중복 state update를 피하세요.