Appearance
Creating wallets
Privy enables your app to easily create new wallets on any EVM network or Solana.
Using the SDK
To create a new wallet, use the Privy client's walletApi.create
method. As parameters to the method, pass the following:
Parameter | Type | Description |
---|---|---|
chainType | 'ethereum' | 'solana | Chain type of the wallet to create. 'Ethereum' supports any EVM-compatible network. |
idempotencyKey | string | (Optional) Idempotency key to identify a unique request. |
authorizationKeyIds | string[] | (Optional) List of authorization key IDs that should be allowed to approve transactions for the wallet. |
authorizationThreshold | number | (Optional) The number of authorization key signatures required to approve a transaction. This number must be less than or equal to the number of length of authorizationKeyIds . If not specified, all keys in the authorizationKeyIds list are required. |
Once invoked, walletApi.create
will request Privy's API to create the desired wallet. The method returns a Promise for an object containing the following:
Field | Type | Description |
---|---|---|
id | string | Unique ID for the created wallet. Used when requesting signatures or transactions from the wallet in the future. |
address | string | Address of the created wallet. |
chainType | 'ethereum' | 'solana | Chain type of the created wallet. |
Below is an example code snippet creating a wallet using the SDK
ts
const {id, address, chainType} = await privy.walletApi.create({chainType: 'ethereum'});
Using the REST API
To create a new wallet, make a POST
request to:
sh
https://api.privy.io/v1/wallets
Body
In the request body, include the following:
Field | Type | Description |
---|---|---|
chain_type | 'ethereum' | 'solana | Chain type of the wallet to create. 'Ethereum' supports any EVM-compatible network. |
idempotency_key | string | (Optional) Idempotency key to identify a unique request. |
authorization_key_ids | string[] | (Optional) List of authorization key IDs that should be allowed to approve transactions for the wallet. |
authorization_threshold | number | (Optional) The number of authorization key signatures required to approve a transaction. This number must be less than or equal to the number of length of authorization_key_ids . If not specified, all keys in the authorization_key_ids list are required. |
Response
In the response, Privy will send back the following if successful:
Field | Type | Description |
---|---|---|
id | string | Unique ID of the created wallet. This will be the primary identifier when using the wallet in the future. |
chain_type | 'ethereum' | 'solana | Chain type of the created wallet. |
address | string | Address of the created wallet. |
Example
As an example, a sample request to create a new EVM wallet might look like the following:
bash
$ curl --request POST https://api.privy.io/v1/wallets \
-u "<your-privy-app-id>:<your-privy-app-secret>" \
-H "privy-app-id: <your-privy-app-id>" \
-H "privy-authorization-signature: <authorization-signature-for-request>" \
-H 'Content-Type: application/json' \
-d '{
"chain_type": "ethereum"
}'
A successful response will look like the following:
json
{
"id": "fmfdj6yqly31huorjqzq38zc",
"address": "0xf9f284C7Eaf97b0f9B5542d83Af7F785D12E803a",
"chain_type": "ethereum"
}