Get started with EVM networks
The StarKey browser extension and mobile in-app browser are both designed to interact with web applications.
StarKey injects a single window.starkey object into every page. Because StarKey is a multi-chain wallet, each network is exposed as its own namespace on that object — for EVM networks, this is window.starkey.ethereum.
For legacy compatibility, StarKey’s EVM provider is also injected directly at window.ethereum.
This provider conforms to two standards:
- EIP-1193 — the common EVM provider interface (
request,on, events) that every method on this page builds on. - EIP-6963 — multi-wallet discovery, so a dApp can find StarKey alongside other installed wallets without conflicts on
window.ethereum.
Detecting the Provider
There are two ways to detect StarKey’s EVM provider: a direct check on window, or standards-based discovery via EIP-6963. Use direct injection for the simplest integration; use EIP-6963 when your dApp needs to list and let the user pick between multiple installed wallets.
Option 1: Direct injection
Check for the namespaced provider at window.starkey.ethereum (recommended), falling back to the legacy window.ethereum if needed:
const getProvider = () => {
if (typeof window === 'undefined') return undefined
const provider = window.starkey?.ethereum ?? window.ethereum
if (provider) {
return provider
}
window.open('https://starkey.app/', '_blank')
}Extension injection can happen asynchronously right after page load, so if you check on initial render, poll briefly before giving up:
const checkIsExtensionInstalled = (): void => {
const intervalId = setInterval(() => {
if (window.starkey?.ethereum) {
clearInterval(intervalId)
setIsExtensionInstalled(true)
}
}, 500)
setTimeout(() => clearInterval(intervalId), 5000)
}Direct injection is simplest, but if the user has multiple EVM wallet extensions installed, they can overwrite one another on the shared window.ethereum object. Use EIP-6963 discovery below to avoid that conflict.
Option 2: EIP-6963 discovery
EIP-6963 lets every installed wallet announce itself independently, so your dApp can discover StarKey by name/RDNS rather than fighting over a single window.ethereum slot.
interface EIP6963ProviderInfo {
uuid: string
name: string
icon: string
rdns: string
}
interface EIP6963ProviderDetail {
info: EIP6963ProviderInfo
provider: unknown // EIP-1193 provider
}
const discoveredProviders = new Map<string, EIP6963ProviderDetail>()
function onAnnouncement(event: CustomEvent<EIP6963ProviderDetail>) {
discoveredProviders.set(event.detail.info.uuid, event.detail)
}
window.addEventListener('eip6963:announceProvider', onAnnouncement as EventListener)
window.dispatchEvent(new Event('eip6963:requestProvider'))StarKey’s RDNS is app.starkey. Once providers have announced themselves, pick StarKey out by that identifier:
const starkeyDetail = [...discoveredProviders.values()].find((detail) => detail.info.rdns === 'app.starkey')
const provider = starkeyDetail?.providerThis section covers detecting the provider, establishing a connection, reading and switching networks, sending transactions, signing messages, listening for events, and error handling.