Skip to content

EvmAccountMappingProvider

EvmAccountMappingProvider is a provider implementation that uses the EVM account mapping pallet. It use viem to interact with EVM wallet, so yuo can use almost all EVM wallets (since all of them can be integrated with viem).

Usage

Follow up is two snippets to show how it works with browser wallet extension and init from a private key.

Browser Extension
import { EvmAccountMappingProvider } from '@phala/sdk'
import { createWalletClient, custom } from 'viem'
import { mainnet } from 'viem/chains'
 
const walletClient = createWalletClient({ chain: mainnet, transport: custom((window as any).ethereum) })
const [address] = await walletClient.requestAddresses()
const provider = await EvmAccountMappingProvider.create(client.api, walletClient, { address })

create

Get a provider instance and connected to the EVM wallet.

Parameters

api

ApiPromise

walletClient

WalletClient

The WalletClient instance from viem. You can learn more about that from the viem documentation.

account

Account

A JSON-RPC Account or Local Account (Private Key, etc) from viem.

Or you can use a plain literval object with address property.

options (optional)

EvmAccountMappingProviderOptions

  • msg: string. The message request to access the public key of selected wallet.
  • SS58Prefix: number. The SS58 prefix for the mapped substrate address.

evmAccount

Account

The Account object for the EVM wallet.

compressedPubkey

Address

The compressed public key for the EVM wallet.