Skip to content

Porto.create

Creates a new Porto instance.

Imports

Named
import { Porto } from 'porto'

Examples

The simplest way to create a new Porto instance is to call the Porto.create() function. This will automatically inject Porto's provider into your Application via EIP-6963.

import { Porto } from 'porto'
 
Porto.create()

Accessing the Provider

You can access Porto's EIP-1193 Provider directly via the provider instance.

import { Porto } from 'porto'
 
const porto = Porto.create()
 
const accounts = await porto.provider.request({
  method: 'wallet_connect',
})

Parameters

announceProvider

  • Type: boolean
  • Default: true

Whether to announce the provider via EIP-6963.

authUrl

  • Type: string | { logout: string; nonce: string; verify: string } | undefined

URL(s) to use for SIWE authentication.

chains

  • Type: readonly [Chains.Chain, ...Chains.Chain[]]
  • Default: [Chains.baseSepolia]

List of supported chains.

feeToken

  • Type: 'native' | string
  • Default: native

Token to use to pay for fees. Accepts:

  • "native": The native token of the chain.
  • Symbol: Symbol of the fee token (e.g. "USDC").
  • Address: Address of the fee token (e.g. "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef").

merchantUrl

  • Type: string | undefined

URL to use for merchant functionality (e.g. fee sponsorship, subsidizing, etc).

mode

  • Type: Mode.Mode
  • Default: Mode.dialog()

Mode to use.

Available:

  • Mode.contract(): Requests & signing is handled locally, and coordinated with the delegation contract.
  • Mode.dialog(): Requests & signing is handled via an iframe or popup dialog.
  • Mode.relay(): Requests & signing is handled locally, and coordinated with the Porto RPC.

relay

  • Type: Transport
  • Default: http('https://rpc.porto.sh')

Relay RPC Transport override.

storage

  • Type: Storage.Storage
  • Default: Storage.idb()

Storage to use.

Available:

transports

  • Type: { [chainId: string]: Transport }
  • Default: {}

Public RPC Transport overrides to use for each chain.

Return Type

Porto

The Porto instance.