Skip to content

Overview

Porto ships with first-class modules that extend and compose with Viem, such as: Wallet Actions, RPC Server Actions, a Porto-specific Account implementation, and more.

Getting Started

Application Developers

Application Developers can use the Porto Dialog with Viem by passing Porto's EIP-1193 provider as a transport to a Viem Client.

Once instantiated, you can utilize Viem's Wallet Actions to interact with Porto, or Porto's custom WalletActions module.

import { createClient, custom, parseEther } from 'viem'
import { Porto } from 'porto'
import { WalletActions } from 'porto/viem' 
import * as Actions from 'viem/actions' 
 
// Instantiate a Porto instance. 
const porto = Porto.create() 
 
// Instantiate a Viem Client with Porto's EIP-1193 provider. //
const client = createClient({ 
  transport: custom(porto.provider), 
}) 
 
const { accounts } = await WalletActions.connect(client)
 
const { id } = await Actions.sendCalls(client, {
  account: '0x',
  calls: [{ to: '0x...', value: parseEther('0.001') }],
})

Wallet Developers

Wallet and Account Developers can use the Porto RPC Server with Viem by instantiating a Viem Client with a Porto-compatible Chain.

Once instantiated, you can utilize Viem's Public Actions or the custom ServerActions module to interact with the RPC Server.

import { createClient, http } from 'viem'
import { Chains } from 'porto'
import { Key, ServerActions } from 'porto/viem'
import * as Actions from 'viem/actions'
 
const client = createClient({ 
  chain: Chains.baseSepolia, 
  transport: http(), 
}) 
 
const account = await ServerActions.createAccount(client, {
  authorizeKeys: [Key.createSecp256k1()],
})
 
const chainId = await Actions.getChainId(client)