Skip to main content

Connecting wallet

Passport is a valid EIP-1193 provider with support for all major RPC methods.

To create an EIP-1193 Passport provider all you need to do is call passportInstance.connectEvm() after initialising Passport.

// fetch the Passport provider from the Passport instance
const passportProvider = passportInstance.connectEvm();

Once a EIP-1193 provider is created, you can call various methods on it via the request function (which is protocol-agnostic), for example:

// calling eth_requestAccounts triggers the Passport login flow
const accounts = await passportProvider.request({ method: 'eth_requestAccounts' });

Calling the eth_requestAccounts request method will trigger the login flow for Passport if the user is not signed in.

Checkout the full working example here: Passport with NextJS Connect with EIP1193.

Provider Events

As per the EIP-1193 specification, the zkEVM provider exposes an on and removeListener function, which can be used to subscribe to and unsubscribe from events emitted by the zkEVM provider

Supported Events

Accounts Changed

The zkEVM provider will emit an accountsChanged event when the accounts available to the provider changes (for example, when eth_requestAccounts is called and the users wallet is initialised):

// listen to the ACCOUNTS_CHANGED event and update the accounts state when it changes
passportProvider.on(ProviderEvent.ACCOUNTS_CHANGED, (accounts: string[]) => {
setAccountsState(accounts);
});