Account Abstraction
Implement ERC-4337 Account Abstraction with Para Server SDK
Account Abstraction (AA) enables powerful smart contract wallet functionality like batched transactions, gas sponsorship, and advanced access controls. Para Server SDK supports integration with leading AA providers, allowing you to implement these capabilities in server-side environments.
When using Account Abstraction with Para, your Para wallet acts as the EOA (Externally Owned Account) signer that controls the smart contract wallet. The AA provider deploys and manages the smart contract wallet on-chain, while Para handles the secure signing required for authorizing transactions.
Server-side AA implementation functions identically to client-side implementation, with the additional requirement of signature byte adjustment for contract verification.
Understanding Signature Adjustment
Account Abstraction providers use on-chain signature verification within their smart contracts. Para’s 2/2 MPC wallet produces non-deterministic signatures where the last byte (v
recovery byte) may need adjustment for proper on-chain verification.
Critical: Para signatures may require adjustment of the last byte for compatibility with AA providers. Without this adjustment, transactions might fail at the network level despite signature success.
Implementation Steps
Let’s break down the process of implementing Account Abstraction on the server into manageable steps:
1. Set Up Para Server Client
First, initialize the Para Server SDK and authenticate with an imported session:
If you need more details on setup please refer tot he Server Setup Guide.
2. Create a Viem Client
Next, use Para’s Viem integration to create a Viem client:
3. Implement Signature Adjustment
Create a helper function to properly adjust the signature byte for on-chain verification:
As mentioned earlier, this function adjusts the last byte of the signature to ensure compatibility with on-chain verification. This is crucial for successful transaction execution when working with Account Abstraction providers.
4. Override Viem Client’s Sign Function
Apply the custom signing function to the Viem client:
5. Create the AA Provider Client
Finally, create the Account Abstraction client using your preferred provider. Here’s an example with Alchemy:
Using the AA Smart Wallet
Once your AA client is set up, you can perform transactions through the smart contract wallet:
Get Smart Wallet Address
First, retrieve the smart wallet address (this is different from your Para wallet address):
Be aware that funds should be sent to the smart wallet address (returned by getAddress()
) rather than the Para wallet address. The smart wallet is the entity that holds funds and executes transactions on-chain.
Send Transactions
Execute transactions through the smart wallet:
Execute Contract Interactions
Interact with smart contracts through your AA wallet:
Supported AA Providers
Para integrates with several leading Account Abstraction providers:
Troubleshooting
Best Practices
-
Always adjust signatures: Implement the signature adjustment function to ensure compatibility with on-chain verification.
-
Test thoroughly: Before deploying to production, test your AA implementation in a test environment with minimal funds.
-
Handle errors gracefully: Implement proper error handling for signature failures and transaction rejections.
-
Monitor gas costs: Be aware of the additional gas costs associated with AA transactions, especially for contract deployments.
-
Secure session management: Follow secure practices for managing Para sessions in server environments.
-
Consider gas sponsorship: Many AA providers offer gas sponsorship, which can improve user experience by eliminating gas fees.
Learn More
For more detailed information on Account Abstraction concepts and implementation, refer to our web documentation:
Examples
Explore our server-side Account Abstraction examples: