Start typing to search...

WEB3.providers

Native web3 provider that leverages Koji for multi-wallet support.

Methods

.isConnected()

Gets whether or not the session is connected

Returns

Promise<Boolean>, Is connected

Example

const isConnected = await Koji.web3.providers.ethereum.isConnected();

Source: frontend/web3/providers/ethereum.ts#L67

.on(event, callback)

Register an event listener for wallet events.

Parameters

  • event - 'accountsChanged' | 'chainChanged' | 'connect' | 'disconnect' | 'message', The name of the event for which to listen.

  • callback - , Called when the event is received

Example

Koji.web3.providers.ethereum.on('accountsChanged', ({ accounts }) => {
  console.log(accounts);
})

Source: frontend/web3/providers/ethereum.ts#L142

.request(args)

Proxies a request to an Ethereum wallet provider.

Parameters

Returns

Promise<Web3RequestResult>, Request result

Example

const accounts = await Koji.web3.providers.ethereum.request({ method: 'eth_requestAccounts' });

Source: frontend/web3/providers/ethereum.ts#L112

.sendAsync(payload, callback)

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.

Parameters

Returns

Promise<Void>

Source: frontend/web3/providers/ethereum.ts#L161

.setPreferredChain(chain)

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.

Parameters

Returns

Promise<Void>

Example

await Koji.web3.providers.ethereum.setPreferredChain('polygon');

Source: frontend/web3/providers/ethereum.ts#L91

Interfaces

DeprecatedJsonRpcRequest

Deprecated Web3 JSON-RPC request

Properties

  • id - String

  • jsonrpc - '2.0'

  • method - String

  • params - Any[] (Optional)

Web3Request

A web3 request to proxy

Properties

  • method - String

  • params - Any[] (Optional)

Web3RequestResult

Result of a proxied web3 request

Properties

  • error -  (Optional)

  • result - Unknown

Type aliases

SupportedChain

Supported chains

Possible values

  • 'ethereum'
  • 'polygon'
  • 'ropsten'
  • 'rinkeby'
  • 'goerli'
  • 'kovan'
  • 'matic_mumbai'