PERS implements a counterfactual wallet system that provides users with blockchain addresses before their first transaction. The system automatically determines the best execution strategy for each transaction request.
- Address Generation: Users receive a deterministic wallet address immediately upon account creation
- Zero Cost: No blockchain fees required for initial wallet setup
- Pre-Computed: Wallet address exists mathematically before being deployed on-chain
- Receiving Tokens: Users can receive tokens to their address immediately
- Multi-Chain Support: Same address calculation across different blockchain networks
When users make their first transaction, the system automatically determines whether to:
- Execute immediately (for internal wallets)
- Prepare for signing (for external wallets)
- Provide setup guidance (when wallet configuration is needed)
The system provides a single transaction endpoint that automatically handles complexity:
Endpoint: POST /transactions
The API automatically handles the complexity of determining execution strategy and provides appropriate responses.
The API returns a unified response structure that eliminates frontend complexity:
interface TransactionRequestResponseDTO {
transaction: TransactionDTO; // Always present
signingData?: AnyTransactionData; // Present when client signing required
walletStatus: WalletSigningScenarioType; // Execution strategy indicator
actionable?: ActionableWalletResponse; // Guidance when setup needed
}The system supports multiple signing account providers for flexible wallet integration.
- ACTIVE: Account is ready for use with all required information
- INACTIVE: Account is temporarily disabled but can be reactivated
- REVOKED: Account is permanently disabled and cannot be used
The system identifies different wallet states and provides appropriate responses:
- WALLET_AND_SIGNING_READY: Wallet exists with active signing capability
- WALLET_MISSING_SIGNING: Wallet exists but lacks signing account
- WALLET_NOT_FOUND: No wallet found for the user
When wallet setup is required, the system provides actionable information:
interface ActionableWalletResponse {
message: string; // User-friendly guidance message
actionUrl?: string; // URL for wallet setup/signup
actionType: 'SIGN_UP' | 'LINK_WALLET' | 'CREATE_SIGNING_ACCOUNT' | 'NONE';
priority: 'LOW' | 'MEDIUM' | 'HIGH';
category: 'WALLET_CREATION' | 'WALLET_CONFIGURATION' | 'WALLET_READY';
}
## API Integration Patterns
### **Unified Transaction Creation**
Frontend applications use a single endpoint regardless of wallet type or execution strategy:
```typescript
// Single API call for all transaction types
const response = await fetch('/transactions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${userToken}`,
'x-project-key': projectKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
transactionType: 'SPEND',
recipient: { accountId: 'recipient-id', accountType: 'USER' },
token: { tokenDbId: 'token-uuid' },
amount: 100
})
});
const result = await response.json();Frontend handles different execution strategies based on the response:
// Intelligent response handling
if (result.walletStatus === 'WALLET_AND_SIGNING_READY') {
// Transaction completed server-side
showSuccess(result.transaction);
} else if (result.walletStatus === 'WALLET_MISSING_SIGNING' && result.signingData) {
// Client signing required
const signature = await userWallet.signTransaction(result.signingData);
await submitSignedTransaction(result.transaction.id, signature);
} else if (result.actionable) {
// Setup required - guide user
showWalletSetupDialog(result.actionable);
}The API supports different authentication methods:
- User Authentication:
Authorization: Bearer {userToken} - Admin Authentication:
Authorization: Bearer {adminToken} - Project Authentication:
x-project-key: {projectKey}
- Instant Participation: Users can start participating immediately
- No Upfront Costs: Eliminates blockchain transaction fees for new users
- Progressive Enhancement: Advanced features unlock as users engage more deeply
- Reduced Gas Costs: Only active users incur deployment costs
- Predictable Costs: Clear cost structure for wallet deployment and transactions
The backend automatically handles wallet capability detection and execution strategy routing.
- Deterministic Address Generation: Consistent address calculation using factory contracts
- Multi-Chain Compatibility: Same address calculation across different blockchain networks
- Counterfactual Deployment: Wallets deployed only when first outgoing transaction occurs
HTTP Request
POST /transactions
Authorization: Bearer {token}
X-Project-Key: {projectKey}
Content-Type: application/jsonRequest Body:
{
"transactionType": "SPEND",
"recipient": {
"accountId": "user_123",
"accountType": "USER"
},
"token": {
"tokenDbId": "token_456",
"chainId": 1
},
"amount": 100
}Response Example:
{
"transaction": {
"id": "txn_123",
"status": "PENDING",
"amount": "100",
"tokenId": "token_456"
},
"walletStatus": "WALLET_AND_SIGNING_READY",
"signingData": null
}HTTP Request
POST /transactions/{transactionId}/submit
Authorization: Bearer {userToken}
X-Project-Key: {projectKey}
Content-Type: application/jsonRequest Body:
{
type: "EIP_712" | "LEGACY" | "EIP_1559",
signature?: string, // For EIP-712
signedTransaction?: string // For other formats
}HTTP Request
POST /auth/token
X-Project-Key: {projectKey}
Content-Type: application/jsonRequest Body:
{
authToken: string // Token from external provider (DFNS, etc.)
}- Implement unified
/transactionsendpoint for all transaction types - Handle both immediate execution and signing preparation responses
- Implement actionable error handling for setup scenarios
- Use proper authentication headers
- Add transaction status tracking
- Authentication Setup: Implement user authentication using
/auth/tokenendpoint - Transaction Integration: Use unified
/transactionsendpoint for all transaction types - Response Handling: Implement intelligent response handling for different execution strategies
- Error Management: Handle actionable responses for wallet setup scenarios
- Testing: Validate all scenarios including server execution, client signing, and setup flows
For detailed implementation assistance, contact our integration team or refer to the complete API documentation.