Provider
An EIP-1193-compatible provider backed by a WalletConnect v2 session.
Application code should call Provider.init; tests that need an isolated or injected instance should call Provider.create.
Example
Section titled “Example”import { Provider } from "konekt";import { ethereumMainnet } from "konekt/eip155";
const provider = await Provider.init({ projectId, metadata, chains: [ethereumMainnet],});
provider.on("display_uri", showPairingUri);await provider.connect();Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Provider(
opts,deps?):Provider
Constructs a provider synchronously.
Prefer Provider.init in applications and Provider.create in tests because those methods perform asynchronous seed loading and session restoration.
Parameters
Section titled “Parameters”ProviderDeps = {}
Returns
Section titled “Returns”Provider
Properties
Section titled “Properties”isWalletConnect
Section titled “isWalletConnect”
readonlyisWalletConnect:true
Allows provider consumers to identify this as a WalletConnect-backed provider.
projectId
Section titled “projectId”
readonlyprojectId:string
The WalletConnect Cloud project ID this provider was configured with.
Accessors
Section titled “Accessors”accountsByChain
Section titled “accountsByChain”Get Signature
Section titled “Get Signature”get accountsByChain():
Record<string,string[]>
Approved addresses grouped by CAIP-2 chain ID across all namespaces in the current session.
Example
Section titled “Example”{ "eip155:1": ["0x…"], "cosmos:cosmoshub-4": ["cosmos1…"] }Returns
Section titled “Returns”Record<string, string[]>
chains
Section titled “chains”Get Signature
Section titled “Get Signature”get chains(): readonly
Chain[]
The configured chains this provider proposes, flattened into one list.
This is configuration, not proof that the wallet approved every chain. Read session to inspect the approved namespaces.
Returns
Section titled “Returns”readonly Chain[]
connected
Section titled “connected”Get Signature
Section titled “Get Signature”get connected():
boolean
Whether the provider currently has an approved session.
Returns
Section titled “Returns”boolean
session
Section titled “session”Get Signature
Section titled “Get Signature”get session():
Session|undefined
The approved session, or undefined before connection and after disconnection.
Returns
Section titled “Returns”Session | undefined
Get Signature
Section titled “Get Signature”get uri():
string|undefined
The temporary pairing URI for the current proposal, when one exists.
Returns
Section titled “Returns”string | undefined
Methods
Section titled “Methods”connect()
Section titled “connect()”connect(
__namedParameters?):Promise<Session>
Proposes a WalletConnect session and waits for the wallet to approve or reject it.
Listen for display_uri before calling this method. Pass an AbortSignal so closing the
pairing UI can cancel the attempt. If a feature rejects the settled session, this method
disconnects it before rejecting.
Parameters
Section titled “Parameters”__namedParameters?
Section titled “__namedParameters?”signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<Session>
The approved WalletConnect session.
disconnect()
Section titled “disconnect()”disconnect():
Promise<void>
Ends the current session, clears adapter and feature state, and emits disconnect.
Returns
Section titled “Returns”Promise<void>
enable()
Section titled “enable()”enable():
Promise<string[]>
Legacy EIP-1193 shortcut that connects if needed and returns the approved EVM accounts.
New code can call connect and then read the EVM adapter’s accounts property.
Returns
Section titled “Returns”Promise<string[]>
off<
K>(e,fn):void
Removes a listener previously passed to on or once.
Type Parameters
Section titled “Type Parameters”K extends keyof ProviderEvents
Parameters
Section titled “Parameters”K
(p) => void
Returns
Section titled “Returns”void
on<
K>(e,fn):void
Adds an event listener that runs every time the event is emitted.
Type Parameters
Section titled “Type Parameters”K extends keyof ProviderEvents
Parameters
Section titled “Parameters”K
(p) => void
Returns
Section titled “Returns”void
once()
Section titled “once()”once<
K>(e,fn):void
Adds an event listener that removes itself after its first call.
Type Parameters
Section titled “Type Parameters”K extends keyof ProviderEvents
Parameters
Section titled “Parameters”K
(p) => void
Returns
Section titled “Returns”void
removeListener()
Section titled “removeListener()”removeListener<
K>(e,fn):void
Alias for off, provided for EIP-1193 and Node-style event compatibility.
Type Parameters
Section titled “Type Parameters”K extends keyof ProviderEvents
Parameters
Section titled “Parameters”K
(p) => void
Returns
Section titled “Returns”void
request()
Section titled “request()”request(
__namedParameters,chainId?):Promise<{ } |null>
Sends an EIP-1193 request through the adapter that supports its method.
The optional chainId is a configured CAIP-2 ID such as "eip155:8453". It targets this call
only and does not change the active chain. Wallet methods require a connected session; EVM
JSON-RPC reads require a read transport on the selected chain.
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”chainId?
Section titled “chainId?”string
Returns
Section titled “Returns”Promise<{ } | null>
Throws
Section titled “Throws”ProviderRpcError with code 4100 when a wallet method has no session, 4200 when the method or read transport is unsupported, or -32602 for malformed parameters.
create()
Section titled “create()”
staticcreate<C>(opts,deps?):Promise<Provider&ChainExtensions<C>>
Creates an independent provider, primarily for tests.
Pass deps to replace the relay, session, seed, or storage. Supplying deps.session keeps the
provider offline and does not open a real relay socket.
Type Parameters
Section titled “Type Parameters”C extends readonly ChainInput[]
Parameters
Section titled “Parameters”ProviderDeps = {}
Returns
Section titled “Returns”Promise<Provider & ChainExtensions<C>>
A new provider, extended with properties supplied by the configured adapters.
init()
Section titled “init()”
staticinit<C>(opts):Promise<Provider&ChainExtensions<C>>
Creates or returns the application-wide provider.
The first call fixes the provider options; later calls return the same promise. Konekt uses the
default relay and persistent browser storage unless the options override them. Register
display_uri and request_sent listeners before starting work that emits those events.
Type Parameters
Section titled “Type Parameters”C extends readonly ChainInput[]
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<Provider & ChainExtensions<C>>
The shared provider, extended with properties supplied by the configured adapters.