This repository provides a Node-based example showcasing how to integrate the Para SDK into a server environment for transaction signing and wallet management. It demonstrates various scenarios including pre-generated wallets, session-based wallets, and integration with multiple ecosystems such as Ethers, Viem, CosmJS, Solana-Web3, and Alchemy-AA.
-
Pre-Generated Wallet:
Created ahead of time and associated with a user (e.g., viaemail
). Ideal for cases where you want a wallet ready before any signing occurs.
Pre-Generation Integration Guide -
Session-Based Wallet:
Created and managed through active Para user sessions. You import/export sessions as needed, allowing the user’s wallet to be accessed server-side as long as a valid session is present.
Session Management Integration Guide
Refer to these links to explore different integrations. Each file contains detailed comments explaining prerequisites, environment variables, and steps needed before calling the routes.
-
Para API Key:
Required for all routes. Sign up or manage your keys at developer.usepara.com. -
Additional Environment Variables:
Based on the integration you are testing:- For Alchemy-AA:
ALCHEMY_API_KEY
andALCHEMY_GAS_POLICY_ID
are required. - For Pre-Generated Wallets:
ENCRYPTION_KEY
(32 bytes) is needed to securely store the user’s key share in the DB.
Copy
.env.example
to.env
and set the required variables. - For Alchemy-AA:
-
Install Dependencies:
yarn install
-
Configure
.env
:- Set
PARA_API_KEY
. - If using Alchemy-AA, set
ALCHEMY_API_KEY
andALCHEMY_GAS_POLICY_ID
. - If using pre-generated wallets, set
ENCRYPTION_KEY
to securely store user shares.
- Set
-
Start the Server:
yarn dev
The server starts on
http://localhost:3000
.
All routes are mounted under /examples/
and grouped by integration type and scenario. Refer to comments in each file
for details on what is expected in the request body and prerequisites (like having created a wallet first).
-
Create a Pre-Generated Wallet:
curl -X POST http://localhost:3000/examples/wallets/pregen/create \ -H "Content-Type: application/json" \ -d '{"email":"[email protected]"}'
-
Sign with Para (Pre-Gen):
curl -X POST http://localhost:3000/examples/para/pregen \ -H "Content-Type: application/json" \ -d '{"email":"[email protected]"}'
-
Sign with Para (Session-Based):
curl -X POST http://localhost:3000/examples/para/session \ -H "Content-Type: application/json" \ -d '{"session":"<exported_session_string>"}'
Replace endpoints and request bodies accordingly for Ethers, Viem, CosmJS, Solana-Web3, and Alchemy-AA examples.
-
Import the Request:
- Create a new POST request.
- Set the URL, e.g.
http://localhost:3000/examples/ethers/pregen
. - In the "Body" tab, select "raw" and "JSON" format, then provide the required JSON (e.g.,
{"email":"[email protected]"}
).
-
Add Headers:
- Add
Content-Type: application/json
.
- Add
-
Send the Request:
- Click "Send" to execute the request.
- Check the response for signed transactions or success messages.
- For ETH-based operations, change
email
orsession
to reference different users/sessions. - For Solana or Cosmos, adjust RPC endpoints and transaction parameters as needed.
- For Alchemy-AA, ensure you’ve set the correct Alchemy credentials and have created a pre-generated wallet or set up a session.
These examples focus on demonstrating how to integrate Para into your codebase. Before deploying to production:
- Implement proper authentication and authorization.
- Improve error handling and logging.
- Integrate your own business logic, security measures, and monitoring.