EVM Non-Custodial Smart Wallets (Server Side)
Set up a Non-Custodial Smart Wallet in a server environment in 5 minutes
Overview
With Crossmint’s Wallets API, you can create a smart contract wallet with a non-custodial signer that you control. This means that:
- Wallets are controlled by your own keys, which you manage server-side
- Transactions are signed using your private keys, giving you full control over transaction approval and execution
- Programmable functionality can be added to the wallet (i.e. daily spending limits, multi-signature requirements etc.)
This quickstart demonstrates how to create such wallets and send transactions from them on any environment.
1. Create and Configure a Crossmint Project
To get started, create a developer account in the Crossmint Staging Console. Open that link, sign in, and accept the dialog to continue.
Then, navigate to project Settings > General, and change the wallet type to Smart Wallets
.
2. Get an API Key
Once you log in to the console, the next step is to create an API key.
- Navigate to project Integrate > API Keys, and click the “Create new key” button in the “Server-side keys” section
- Under the Wallets API category, select the scopes
wallets.create
,wallets.read
,wallets.fund
,wallets:balance.read
,wallets:transactions.create
,wallets:transactions.read
, andwallets:transactions.sign
- Click “Create server key” to save the key for the next step
3. Generate a Key Pair
Smart Wallets are controlled by one or more secrets that you hold, called the wallet “signers”.
In production, you may want to use passkeys, MPC wallets, or some other secret management service to guard these, but for the purposes of this tutorial, we will generate a key that you can guard in your computer.
4. Create Your Smart Wallet
To create a new non-custodial smart wallet, make a POST request to the Create Wallet endpoint:
5. Fund Your Wallet
Now that your wallet is created, let’s give it some funds so that you can complete your first transaction.
To do so we will call the Fund Wallet endpoint, using the wallet address returned from the previous step as the wallet locator.
6. Get Your Wallet’s Balance
To ensure that the right amount has made it to your wallet, you call the Get Wallet Balance endpoint, just like shown above using the returned wallet locator.
7. Transaction Flow
Now that the wallet is funded, you can send transactions from it, such as transferring currency, interacting with smart contracts, or purchasing items. Custodial smart wallet transactions follow a simple three-step process:
- Create Transaction - Create your intended transaction (i.e. transfer tokens, call a contract)
- Sign Transaction - Sign the transaction with the wallet’s signer
- Approve Transaction - Submit the transaction onchain
Once all approvals are submitted, Crossmint will automatically broadcast the transaction onchain
Here’s a quick visualization of the flow:
The following sections will walk you through implementing each step. You’ll need to:
- Create a transaction with your intended operation
- Sign the approval message and submit it
- Approve the transaction
- Monitor the transaction status
Crossmint automatically broadcasts the transaction once all required approvals are submitted. No manual broadcasting is needed.
A. Create Transaction
Let’s send 4 USDC from your wallet to a new recipient’s address.
The first step is to prepare the transaction’s data. The script below uses Infura’s Base Sepolia RPC endpoint to generate the encoded transaction data needed to transfer 4 USDC, by constructing the transaction using Web3.py.
Now the serialized transaction data can be passed to the Create Transaction endpoint to create the transaction.
B. Sign Transaction
The transaction’s status in the response is “awaiting-approval” as the signer has not yet signed the message shown below.
To complete this step you need to sign the message returned (also referred to as “userOperationHash”) with the signer’s private key.
You can also approve the transaction by generating a signature via Python or JavaScript.
C. Approve Transaction
After signing the message, submit your approval by calling the Approve Transaction endpoint.
Once all required approvals are submitted, Crossmint will automatically broadcast the transaction onchain.
No additional action is required after submitting the approval. If this was the final required approval, the status will
be pending
, showing that Crossmint is broadcasting the transaction onchain
8. Monitor Transaction Status
You can monitor the transaction’s status by polling the Get Transaction endpoint.
The API will return the full transaction, including it’s status, which can be one of the following:
awaiting-approval
: Waiting for required approvalspending
: Broadcasting transaction onchainsuccess
: Transaction successfully executed onchainfailed
: Transaction failed during execution