Documentation Index
Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
Use this file to discover all available pages before exploring further.
Function Signature
Future<PortalProviderResponse> request({
required String chainId,
required String method, // 'eth_signUserOperation'
required List<Object?> params,
String? signatureApprovalMemo,
})
Description
Signs an ERC-4337 UserOperation using the client’s MPC key without broadcasting it to the network. This method is invoked via portal.request() with the method set to eth_signUserOperation. The signed UserOperation can then be submitted through a separate backend (e.g., Pimlico or a custom bundler endpoint).
This method requires the client to be created with Account Abstraction enabled (isAccountAbstracted: true). Non-AA clients will receive a METHOD_UNSUPPORTED error.
Parameters
The params array takes a single object with the following fields:
| Parameter | Type | Required | Description |
|---|
to | String | Yes | The recipient or contract address |
value | String | No | Value in wei (hex-encoded) |
data | String | No | Calldata (hex-encoded) |
gas | String | No | Gas limit (hex-encoded) |
maxFeePerGas | String | No | Max fee per gas for EIP-1559 (hex-encoded) |
maxPriorityFeePerGas | String | No | Max priority fee for EIP-1559 (hex-encoded) |
nonce | String | No | Transaction nonce (hex-encoded) |
Returns
PortalProviderResponse - An object containing:
| Property | Type | Description |
|---|
result | dynamic | A hex-encoded JSON string containing the signed UserOperation |
error | dynamic | Error information if the call failed |
Example
import 'package:portal_flutter/portal_flutter.dart';
final portal = Portal();
// Sign a UserOperation on Sepolia testnet
final result = await portal.request(
chainId: 'eip155:11155111',
method: 'eth_signUserOperation',
params: [
{
'to': '0xRecipientAddress',
'value': '0x0',
'data': '0x',
}
],
);
if (result.error != null) {
print('Error: ${result.error}');
} else {
print('Signed UserOp: ${result.result}');
}
With EIP-1559 Gas Parameters
final result = await portal.request(
chainId: 'eip155:11155111',
method: 'eth_signUserOperation',
params: [
{
'to': '0xRecipientAddress',
'value': '0xDE0B6B3A7640000', // 1 ETH in wei
'data': '0x',
'maxFeePerGas': '0x3B9ACA00',
'maxPriorityFeePerGas': '0x3B9ACA00',
}
],
);
Errors
| Code | Description |
|---|
METHOD_UNSUPPORTED | The client does not have Account Abstraction enabled |
NOT_INITIALIZED | Portal was not initialized |
RPC_ERROR | The RPC call returned an error |