Events
info
Universal Provider emits two events through the EventEmitter API on Node.js.
1. accountsChanged
- The
dapp:accountsChanged
event is triggered when an account change is detected inside the network. Returns the changed account addressaddress
and current chain nameCHAIN_NAME
in the formCHAIN_NAME:address
as the input argument from a callback function.
type CHAIN_NAME = 'celestia' | 'celo' | 'cosmos' | 'ethereum' | 'juno' | 'klaytn' | 'near' | 'neon' | 'solana';
window.dapp.on('dapp:accountsChanged', (currentAccount: string) => {
console.log(currentAccount); // near:welldone.testnet
});
2. chainChanged
- The
dapp:chainChanged
event is triggered when a network change inside the chain is identified. Returns the network IDnetworkID
and current chain nameCHAIN_NAME
in the formCHAIN_NAME:networkID
as modified by the input argument on a callback function.
type CHAIN_NAME = 'celestia' | 'celo' | 'cosmos' | 'ethereum' | 'juno' | 'klaytn' | 'near' | 'neon' | 'solana';
window.dapp.on('dapp:chainChanged', (currentNetwork: string) => {
console.log(currentNetwork); //celo:0xf370
});