Para Class
The Para
class is the main entry point for the Para Flutter SDK, providing wallet operations, authentication, and blockchain interactions.
Constructor
Creates a new Para SDK instance.
The environment to use: Environment.dev
, Environment.sandbox
, Environment.beta
, or Environment.prod
.
Your Para API key for authentication.
Your appβs deep link scheme for OAuth/WebAuth callbacks (e.g., βyourapp://callbackβ).
Optional configuration object for advanced settings.
final para = Para (
environment : Environment .beta,
apiKey : 'YOUR_API_KEY' ,
deepLinkScheme : 'yourapp://callback' ,
config : ParaConfig (
jsBridgeUri : Uri . parse ( 'custom-bridge-url' ), // Optional
relyingPartyId : 'custom.domain.com' , // Optional
),
);
Authentication Methods
Initiates authentication flow for email or phone. Returns an AuthState
indicating next steps.
auth
Map<String, String>
required
Authentication map containing either {'email': 'user@example.com'}
or {'phone': '+1234567890'}
.
// Email authentication
final authStateFuture = para. signUpOrLogIn (
auth : { 'email' : 'user@example.com' }
);
final authState = await authStateFuture.future;
// Phone authentication
final authStateFuture = para. signUpOrLogIn (
auth : { 'phone' : '+1234567890' }
);
final authState = await authStateFuture.future;
Verifies a new account with the verification code sent to email/phone.
The 6-digit verification code.
final verifiedStateFuture = para. verifyNewAccount (
verificationCode : '123456'
);
final verifiedState = await verifiedStateFuture.future;
Logs in an existing user with their passkey using native device authentication.
Optional email for the user (either email or phone should be provided).
Optional phone number for the user (either email or phone should be provided).
final walletFuture = para. loginWithPasskey (
email : 'user@example.com'
);
final wallet = await walletFuture.future;
Handles complete OAuth authentication flow using an external browser.
OAuth provider: OAuthMethod.google
, .twitter
, .apple
, .discord
, or .facebook
.
Your appβs deep link URL scheme for OAuth callback.
final authState = await para. verifyOAuth (
provider : OAuthMethod .google,
deeplinkUrl : 'yourapp://callback' ,
);
Wallet Management
Creates a new wallet. Returns a ParaFuture
that can be cancelled.
The type of wallet to create: WalletType.evm
, .solana
, or .cosmos
(default: WalletType.evm
).
Whether to skip the distributed backup process.
final walletFuture = para. createWallet (
type : WalletType .evm,
skipDistribute : false ,
);
final wallet = await walletFuture.future;
// Or cancel: await para.cancelOperationById(walletFuture.requestId);
Retrieves all wallets for the current user.
final walletsFuture = para. fetchWallets ();
final wallets = await walletsFuture.future;
Signing Operations
signMessage()
ParaFuture<SignatureResult>
Signs a message with the specified wallet. Returns a cancellable ParaFuture
.
The wallet ID to use for signing.
The message to sign, base64-encoded.
Optional timeout in milliseconds (default: 30000).
For Cosmos signing: The SignDoc as base64-encoded JSON. When provided, this method signs a Cosmos transaction instead of a generic message.
// Generic message signing
final signatureFuture = para. signMessage (
walletId : wallet.id,
messageBase64 : base64Encode (utf8. encode ( 'Hello, Para!' )),
);
final signature = await signatureFuture.future;
// Cosmos transaction signing
final cosmosSignature = await para. signMessage (
walletId : cosmosWallet.id,
messageBase64 : '' , // Not used for Cosmos
cosmosSignDocBase64 : base64Encode (utf8. encode ( jsonEncode (signDoc))),
).future;
signTransaction()
ParaFuture<SignatureResult>
Signs an EVM transaction. Returns a cancellable ParaFuture
.
This method is for EVM transactions only. For Solana, use signMessage()
with the serialized transaction as messageBase64
. For Cosmos, use signMessage()
with cosmosSignDocBase64
.
The wallet ID to use for signing.
RLP-encoded EVM transaction (base64).
Chain ID of the EVM network.
Optional timeout in milliseconds (default: 30000).
// EVM transaction signing
final signatureFuture = para. signTransaction (
walletId : evmWallet.id,
rlpEncodedTxBase64 : base64Encode (rlpEncodedTx),
chainId : '1' , // Ethereum mainnet
);
final signature = await signatureFuture.future;
Cancels an ongoing operation by its request ID.
The request ID from a ParaFuture
.
final signatureFuture = para. signMessage (...);
// Cancel the operation
await para. cancelOperationById (signatureFuture.requestId);
Session Management
Checks if thereβs an active user session.
final isActive = await para. isSessionActive ().future;
Exports the current session as an encrypted string.
final sessionData = await para. exportSession ().future;
// Save sessionData securely
Logs out the current user and clears session data.
await para. logout ().future;
Utility Methods
getCurrentUserAuthDetails()
Gets the current userβs authentication details.
final authDetails = await para. getCurrentUserAuthDetails ().future;
waitForLogin()
ParaFuture<Map<String, dynamic>>
Waits for an ongoing login operation to complete.
Optional function to check if operation is canceled.
Polling interval in milliseconds (default: 2000).
final result = await para. waitForLogin (
pollingIntervalMs : 1000 ,
).future;
waitForWalletCreation()
ParaFuture<Map<String, dynamic>>
Waits for wallet creation to complete after signup.
Optional function to check if operation is canceled.
Polling interval in milliseconds (default: 2000).
final result = await para. waitForWalletCreation (
pollingIntervalMs : 1000 ,
).future;
Formats a phone number for authentication.
The phone number to format.
The country code (e.g., β1β for US, β44β for UK).
final formatted = para. formatPhoneNumber ( '1234567890' , '1' );
// Returns: '+11234567890' (exact format depends on implementation)
Checks if the current user is using an external wallet.
final isExternal = await para. isUsingExternalWallet ().future;
Clears local storage data.
Whether to keep the Paillier secret key (default: false).
await para. clearStorage ( false ).future;
Disposes of SDK resources. Call when the SDK is no longer needed.
Extension Methods
Para provides extension methods for cleaner authentication flows (requires importing extensions):
import 'package:para/src/auth_extensions.dart' ;
ParaAuthExtensions
Initiates authentication and returns the current state using Auth
helper class.
Authentication method: Auth.email()
or Auth.phone()
.
// Must import extensions
import 'package:para/src/auth_extensions.dart' ;
final authState = await para. initiateAuthFlow (
auth : Auth . email ( 'user@example.com' )
);
Presents a password authentication URL in a secure web view.
The password authentication URL.
webAuthenticationSession
WebAuthenticationSession
required
Web authentication session for handling the flow.
Blockchain Signers
ParaEvmSigner
EVM-compatible signer for ethers.js integration.
import 'package:para/para_evm_signer.dart' ;
final signer = ParaEvmSigner (
para : para,
walletId : wallet.id, // Optional, uses first EVM wallet if not provided
);
// Use with ethers.js
final provider = JsonRpcProvider ( 'https://rpc-url' );
final contract = Contract (contractAddress, abi, signer);
ParaSolanaWeb3Signer
Solana signer for web3.dart integration.
import 'package:para/para_solana_web3_signer.dart' ;
import 'package:solana_web3/solana_web3.dart' as web3;
final signer = ParaSolanaWeb3Signer (
para : para,
solanaClient : solanaClient, // Required: SolanaClient instance
walletId : wallet.id, // Optional, uses first Solana wallet if not provided
);
// Use signer for transactions
final signedTx = await signer. signTransaction (transaction);
final signature = await signer. sendTransaction (signedTx, connection);
Types and Enums
Environment
enum Environment {
dev, // Development environment
sandbox, // Sandbox for testing
beta, // Beta environment
prod // Production environment
}
class Auth {
static AuthEmail email ( String email);
static AuthPhone phone ( String phoneNumber);
}
AuthState
class AuthState {
final AuthStage stage; // Current authentication stage
final String ? userId; // User's unique identifier
final AuthIdentity auth; // Authentication identity details
final String ? displayName; // User's display name
final String ? pfpUrl; // Profile picture URL
final String ? username; // Username
final Map < String , dynamic > ? externalWallet; // External wallet info
final String ? passkeyUrl; // URL for passkey authentication
final String ? passkeyId; // Passkey identifier
final String ? passwordUrl; // URL for password authentication
// Additional properties for specific auth flows
}
class AuthIdentity {
final String ? email;
final String ? phoneNumber;
final String ? fid; // Farcaster ID
final String ? telegramUserId;
// Other identity types
}
enum AuthStage {
verify, // Need to verify email/phone
login, // Existing user, proceed to login
signup // New user, proceed to signup
}
SignupMethod
enum SignupMethod {
passkey, // Hardware-backed passkey
password // Password-based authentication
}
OAuthMethod
enum OAuthMethod {
google,
twitter,
apple,
discord,
facebook
}
WalletType
enum WalletType {
evm, // Ethereum and EVM-compatible chains
solana, // Solana blockchain
cosmos // Cosmos-based chains
}
ParaFuture
class ParaFuture < T > {
final Future < T > future; // The actual future
final String requestId; // ID for cancellation
}
class Wallet {
final String id;
final String address;
final WalletType type;
final WalletScheme scheme;
final String ? userId; // Associated user ID
final DateTime ? createdAt; // Creation timestamp
final String ? publicKey; // Wallet public key
final bool ? isPregen; // Whether this is a pregenerated wallet
// Additional optional fields available
}
SignatureResult
// Abstract base class
abstract class SignatureResult {}
// Successful signature
class SuccessfulSignatureResult extends SignatureResult {
final String signature;
SuccessfulSignatureResult ( this .signature);
}
// Denied signature
class DeniedSignatureResult extends SignatureResult {
final String ? pendingTransactionId;
DeniedSignatureResult ( this .pendingTransactionId);
}
// Denied with URL
class DeniedSignatureResultWithUrl extends SignatureResult {
final String ? pendingTransactionId;
final String url;
DeniedSignatureResultWithUrl ({ this .pendingTransactionId, required this .url});
}