Mode
Built-in Modes
Mode | Uses | Best for |
---|---|---|
Mode.dialog (default) | Hosted Porto Dialog | Applications |
Mode.rpcServer | Direct to RPC Server | Wallets or Account Managers |
Mode.dialog
Dialog mode embeds the hosted Porto Dialog (an iframe pointing to id.porto.sh
) and forwards every request that requires user interaction to that dialog.
Diagram
In the diagram below, Mode.dialog
is utilized within the Application to communicate with the Porto Dialog (id.porto.sh
).
Usage
import { Porto, Mode } from 'porto'
const porto = Porto.create({
mode: Mode.dialog(),
})
Options
host
- Type:
string
- Default:
"https://id.porto.sh/dialog"
URL of the dialog embed.
import { Porto, Mode } from 'porto'
const porto = Porto.create({
mode: Mode.dialog({
host: 'https://account.my-wallet.com/dialog',
}),
})
renderer
- Type:
Dialog.Dialog
- Default:
Dialog.iframe()
The renderer to use for the dialog. Available: Dialog.iframe
, Dialog.popup
import { Dialog, Porto, Mode } from 'porto'
const porto = Porto.create({
mode: Mode.dialog({
renderer: Dialog.popup(),
}),
})
Mode.rpcServer
Interacts with the Porto RPC Server directly. Signing is performed via the SDK. Account management, chain interop, and transaction management is orchestrated on the RPC Server.
Diagram
In the diagram below, Mode.rpcServer
is utilized within the Porto Dialog (id.porto.sh
) to communicate with the RPC Server.
Usage
import { Porto, Mode } from 'porto'
const porto = Porto.create({
mode: Mode.rpcServer(),
})
Caveats
- When you run
Mode.rpcServer
the Passkey Host (WebAuthn Relying Party) becomes your domain, notid.porto.sh
. Credentials created here cannot be asserted on other domains, which means users cannot reuse their Porto account created onid.porto.sh
.
Options
keystoreHost
- Type:
string
- Default:
"self"
Keystore host (WebAuthn relying party).
import { Porto, Mode } from 'porto'
const porto = Porto.create({
mode: Mode.rpcServer({
keystoreHost: 'https://account.my-wallet.com',
}),
})
permissionsFeeLimit
- Type:
boolean
- Default:
Record<FeeToken.Kind, string>
Fee limit to use for permissions.
import { Porto, Mode } from 'porto'
const porto = Porto.create({
mode: Mode.rpcServer({
permissionsFeeLimit: {
ETH: '0.0001',
USDC: '1',
USDT: '1',
},
}),
})
persistPreCalls
- Type:
boolean
- Default:
true
Whether to store pre-calls in a persistent storage.
If this is set to false
, it is expected that the consumer
will manually store pre-calls, and provide them to actions
that support a preCalls
parameter.
import { Porto, Mode } from 'porto'
const porto = Porto.create({
mode: Mode.rpcServer({
persistPreCalls: false,
}),
})