const isConnected = await Koji.web3.providers.ethereum.isConnected();
Native web3 provider that leverages Koji for multi-wallet support.
Gets whether or not the session is connected
Promise<Boolean>, Is connected
const isConnected = await Koji.web3.providers.ethereum.isConnected();
Register an event listener for wallet events.
event
- 'accountsChanged' | 'chainChanged' | 'connect' | 'disconnect' | 'message', The name of the event for which to listen.
callback
- , Called when the event is received
Koji.web3.providers.ethereum.on('accountsChanged', ({ accounts }) => {
console.log(accounts);
})
Proxies a request to an Ethereum wallet provider.
args
- Web3Request, A web3 request to proxy
Promise<Web3RequestResult>, Request result
const accounts = await Koji.web3.providers.ethereum.request({ method: 'eth_requestAccounts' });
Support deprecated sendAsync method. This method is only implemented
because some assertion libraries check its existance when attaching to a
provider. It should not be used in cases where request
is available.
payload
- DeprecatedJsonRpcRequest, Deprecated Web3 JSON-RPC request
callback
- , Callback with request result
Promise<Void>
Set the chain preferred by this app. For consumers using the Koji native wallet, setting this automatically updates the user’s connected chain. For users of other wallets, Koji will notify the user if they are connected using the non-preferred chain. If not set, defaults to ethereum mainnet.
chain
- SupportedChain, The chain preferred by this app
Promise<Void>
await Koji.web3.providers.ethereum.setPreferredChain('polygon');
Deprecated Web3 JSON-RPC request
id
- String
jsonrpc
- '2.0'
method
- String
params
- Any[] (Optional)
A web3 request to proxy
method
- String
params
- Any[] (Optional)
Result of a proxied web3 request
error
- (Optional)
result
- Unknown
Supported chains