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. These are PEM formatted public keys with escaped newlines. |
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 authorizationKeys . Defaults to 0 if not passed. |
ts
const {id, address, chainType} = await privy.walletApi.create({chainType: 'ethereum'});
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. |
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. These are PEM formatted public keys with escaped newlines. |
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 authorizationKeys . Defaults to 0 if not passed. |
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 request
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"
}
Example request with 2 of 3 quorum signatures
A sample request to create a new EVM wallet with quorum approvals (2 of 3) 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",
"authorization_key_ids": [
"onz3itqhcx667gz3lyxjofui",
"j0uov7pqoy7bnqrt7612prr0",
"eexjdc5g72vfzzqdl7sb1vbj",
],
"authorization_threshold": 2,
}'
A successful response will look like the following:
json
{
"id": "fmfdj6yqly31huorjqzq38zc",
"address": "0xf9f284C7Eaf97b0f9B5542d83Af7F785D12E803a",
"chain_type": "ethereum"
}