Class: Privy::Resources::Wallets

Inherits:
Object
  • Object
show all
Defined in:
lib/privy/resources/wallets.rb,
lib/privy/resources/wallets/earn.rb,
lib/privy/resources/wallets/swap.rb,
lib/privy/resources/wallets/actions.rb,
lib/privy/resources/wallets/balance.rb,
lib/privy/resources/wallets/transactions.rb,
lib/privy/resources/wallets/earn/ethereum.rb,
lib/privy/resources/wallets/earn/ethereum/incentive.rb,
sig/privy/resources/wallets.rbs,
sig/privy/resources/wallets/earn.rbs,
sig/privy/resources/wallets/swap.rbs,
sig/privy/resources/wallets/actions.rbs,
sig/privy/resources/wallets/balance.rbs,
sig/privy/resources/wallets/transactions.rbs,
sig/privy/resources/wallets/earn/ethereum.rbs,
sig/privy/resources/wallets/earn/ethereum/incentive.rbs

Direct Known Subclasses

Services::Wallets

Defined Under Namespace

Classes: Actions, Balance, Earn, Swap, Transactions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Wallets

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Wallets.

Parameters:



538
539
540
541
542
543
544
545
# File 'lib/privy/resources/wallets.rb', line 538

def initialize(client:)
  @client = client
  @actions = Privy::Resources::Wallets::Actions.new(client: client)
  @earn = Privy::Resources::Wallets::Earn.new(client: client)
  @transactions = Privy::Resources::Wallets::Transactions.new(client: client)
  @balance = Privy::Resources::Wallets::Balance.new(client: client)
  @swap = Privy::Resources::Wallets::Swap.new(client: client)
end

Instance Attribute Details

#actionsPrivy::Resources::Wallets::Actions (readonly)

Operations related to wallet actions



8
9
10
# File 'lib/privy/resources/wallets.rb', line 8

def actions
  @actions
end

#balancePrivy::Resources::Wallets::Balance (readonly)

Operations related to wallets



19
20
21
# File 'lib/privy/resources/wallets.rb', line 19

def balance
  @balance
end

#earnPrivy::Resources::Wallets::Earn (readonly)



11
12
13
# File 'lib/privy/resources/wallets.rb', line 11

def earn
  @earn
end

#swapPrivy::Resources::Wallets::Swap (readonly)

Operations for swapping tokens within wallets



23
24
25
# File 'lib/privy/resources/wallets.rb', line 23

def swap
  @swap
end

#transactionsPrivy::Resources::Wallets::Transactions (readonly)

Operations related to wallets



15
16
17
# File 'lib/privy/resources/wallets.rb', line 15

def transactions
  @transactions
end

Instance Method Details

#_init_import(body:, request_options: {}) ⇒ Privy::Models::WalletInitImportResponse

Initialize a wallet import. Complete by submitting the import.

Parameters:

Returns:

See Also:



163
164
165
166
167
168
169
170
171
172
# File 'lib/privy/resources/wallets.rb', line 163

def _init_import(params)
  parsed, options = Privy::WalletInitImportParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/wallets/import/init",
    body: parsed[:body],
    model: Privy::Models::WalletInitImportResponse,
    options: options
  )
end

#_submit_import(wallet:, additional_signers: nil, display_name: nil, external_id: nil, owner: nil, owner_id: nil, policy_ids: nil, request_options: {}) ⇒ Privy::Models::Wallet

Some parameter documentations has been truncated, see Models::WalletSubmitImportParams for more details.

Submit a wallet import request.

Parameters:

Returns:

See Also:



200
201
202
203
204
205
206
207
208
209
# File 'lib/privy/resources/wallets.rb', line 200

def _submit_import(params)
  parsed, options = Privy::WalletSubmitImportParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/wallets/import/submit",
    body: parsed,
    model: Privy::Wallet,
    options: options
  )
end

#_transfer(wallet_id, destination:, source:, amount: nil, amount_type: nil, fee_configuration: nil, slippage_bps: nil, privy_authorization_signature: nil, privy_idempotency_key: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::Wallets::TransferActionResponse

Some parameter documentations has been truncated, see Models::WalletTransferParams for more details.

Transfer tokens from a wallet to a destination address.

Parameters:

  • wallet_id (String)

    Path param: ID of the wallet.

  • destination (Privy::Models::TokenTransferDestination)

    Body param: The destination address for a token transfer. Optionally specify a d

  • source (Privy::Models::NamedTokenTransferSource, Privy::Models::CustomTokenTransferSource)

    Body param: The source asset, amount, and chain for a token transfer. Specify ei

  • amount (String)

    Body param: Amount as a decimal string in the token's standard unit (e.g. "1.5"

  • amount_type (Symbol, Privy::Models::AmountType)

    Body param: Whether the amount refers to the input token or output token.

  • fee_configuration (Privy::Models::FeeConfiguration)

    Body param: Total fees assessed on a transfer, in BPS

  • slippage_bps (Integer)

    Body param: Maximum allowed slippage in basis points (1 bps = 0.01%). Only appli

  • privy_authorization_signature (String)

    Header param: Request authorization signature. If multiple signatures are requir

  • privy_idempotency_key (String)

    Header param: Idempotency keys ensure API requests are executed only once within

  • privy_request_expiry (String)

    Header param: Request expiry. Value is a Unix timestamp in milliseconds represen

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/privy/resources/wallets.rb', line 243

def _transfer(wallet_id, params)
  parsed, options = Privy::WalletTransferParams.dump_request(params)
  header_params =
    {
      privy_authorization_signature: "privy-authorization-signature",
      privy_idempotency_key: "privy-idempotency-key",
      privy_request_expiry: "privy-request-expiry"
    }
  @client.request(
    method: :post,
    path: ["v1/wallets/%1$s/transfer", wallet_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::Wallets::TransferActionResponse,
    options: options
  )
end

#archive(wallet_id, request_options: {}) ⇒ Privy::Models::Wallet

Archives a wallet, preventing it from being used in any write or signing operations. Archived wallets are hidden from list endpoints by default. Returns 404 if the wallet does not exist or is already archived.

Parameters:

  • wallet_id (String)

    ID of the wallet.

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



274
275
276
277
278
279
280
281
# File 'lib/privy/resources/wallets.rb', line 274

def archive(wallet_id, params = {})
  @client.request(
    method: :post,
    path: ["v1/wallets/%1$s/archive", wallet_id],
    model: Privy::Wallet,
    options: params[:request_options]
  )
end

#authenticate_with_jwt(encryption_type:, recipient_public_key:, user_jwt:, request_options: {}) ⇒ Privy::Models::EncryptedWalletAuthenticateResponse, Privy::Models::RawWalletAuthenticateResponse

Some parameter documentations has been truncated, see Models::WalletAuthenticateWithJwtParams for more details.

Exchange a user JWT for a session key authorized to act on the user's wallets. Returns the encrypted authorization key and the list of wallets it can access.

Parameters:

  • encryption_type (Symbol, Privy::Models::WalletAuthenticateRequestBody::EncryptionType)

    The encryption type for the authentication response. Currently only supports HPK

  • recipient_public_key (String)

    The public key of your ECDH keypair, in base64-encoded, SPKI-format, whose priva

  • user_jwt (String)

    The user's JWT, to be used to authenticate the user.

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



302
303
304
305
306
307
308
309
310
311
# File 'lib/privy/resources/wallets.rb', line 302

def authenticate_with_jwt(params)
  parsed, options = Privy::WalletAuthenticateWithJwtParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/wallets/authenticate",
    body: parsed,
    model: Privy::WalletAuthenticateWithJwtResponse,
    options: options
  )
end

#create(chain_type:, additional_signers: nil, display_name: nil, external_id: nil, owner: nil, owner_id: nil, policy_ids: nil, privy_idempotency_key: nil, request_options: {}) ⇒ Privy::Models::Wallet

Some parameter documentations has been truncated, see Models::WalletCreateParams for more details.

Creates a new wallet on the requested chain and for the requested owner.

Parameters:

  • chain_type (Symbol, Privy::Models::WalletChainType)

    Body param: The wallet chain types.

  • additional_signers (Array<Privy::Models::AdditionalSignerItemInput>)

    Body param: Additional signers for the wallet.

  • display_name (String)

    Body param: A human-readable label for the wallet.

  • external_id (String)

    Body param: A customer-provided identifier for mapping to external systems. URL-

  • owner (Privy::Models::OwnerInputUser, Privy::Models::OwnerInputPublicKey, nil)

    Body param: The owner of the resource, specified as a Privy user ID, a P-256 pub

  • owner_id (String, nil)

    Body param: The key quorum ID to set as the owner of the resource. If you provid

  • policy_ids (Array<String>)

    Body param: An optional list of up to one policy ID to enforce on the wallet.

  • privy_idempotency_key (String)

    Header param: Idempotency keys ensure API requests are executed only once within

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/privy/resources/wallets.rb', line 53

def create(params)
  parsed, options = Privy::WalletCreateParams.dump_request(params)
  header_params = {privy_idempotency_key: "privy-idempotency-key"}
  @client.request(
    method: :post,
    path: "v1/wallets",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::Wallet,
    options: options
  )
end

#create_batch(wallets:, request_options: {}) ⇒ Privy::Models::WalletBatchCreateResponse

Creates multiple wallets in a single request. Each wallet creation is independent; failures for one wallet do not affect others. Maximum batch size is 100 wallets.

Parameters:

Returns:

See Also:



326
327
328
329
330
331
332
333
334
335
# File 'lib/privy/resources/wallets.rb', line 326

def create_batch(params)
  parsed, options = Privy::WalletCreateBatchParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/wallets/batch",
    body: parsed,
    model: Privy::WalletBatchCreateResponse,
    options: options
  )
end

#create_wallets_with_recovery(primary_signer:, recovery_user:, wallets:, request_options: {}) ⇒ Privy::Models::WalletCreateWalletsWithRecoveryResponse

Deprecated.

Create one or more wallets associated with a recovery user, so the user can later regain wallet access via the linked accounts. Deprecated; prefer the standard wallet creation flow combined with a separate recovery setup.



353
354
355
356
357
358
359
360
361
362
# File 'lib/privy/resources/wallets.rb', line 353

def create_wallets_with_recovery(params)
  parsed, options = Privy::WalletCreateWalletsWithRecoveryParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/wallets_with_recovery",
    body: parsed,
    model: Privy::WalletCreateWalletsWithRecoveryResponse,
    options: options
  )
end

#export(wallet_id, encryption_type:, recipient_public_key:, export_seed_phrase: nil, privy_authorization_signature: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::WalletExportResponseBody

Some parameter documentations has been truncated, see Models::WalletExportParams for more details.

Export a wallet's private key

Parameters:

  • wallet_id (String)

    Path param: ID of the wallet.

  • encryption_type (Symbol, Privy::Models::HpkeEncryption)

    Body param: The encryption type of the wallet to import. Currently only supports

  • recipient_public_key (String)

    Body param: The base64-encoded encryption public key to encrypt the wallet priva

  • export_seed_phrase (Boolean)

    Body param

  • privy_authorization_signature (String)

    Header param: Request authorization signature. If multiple signatures are requir

  • privy_request_expiry (String)

    Header param: Request expiry. Value is a Unix timestamp in milliseconds represen

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/privy/resources/wallets.rb', line 388

def export(wallet_id, params)
  parsed, options = Privy::WalletExportParams.dump_request(params)
  header_params =
    {
      privy_authorization_signature: "privy-authorization-signature",
      privy_request_expiry: "privy-request-expiry"
    }
  @client.request(
    method: :post,
    path: ["v1/wallets/%1$s/export", wallet_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::WalletExportResponseBody,
    options: options
  )
end

#get(wallet_id, include_archived: nil, request_options: {}) ⇒ Privy::Models::Wallet

Get a wallet by wallet ID.

Parameters:

  • wallet_id (String)

    ID of the wallet.

  • include_archived (Boolean)

    Include archived wallets in lookup. Defaults to false.

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



418
419
420
421
422
423
424
425
426
427
428
# File 'lib/privy/resources/wallets.rb', line 418

def get(wallet_id, params = {})
  parsed, options = Privy::WalletGetParams.dump_request(params)
  query = Privy::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v1/wallets/%1$s", wallet_id],
    query: query,
    model: Privy::Wallet,
    options: options
  )
end

#get_wallet_by_address(address:, include_archived: nil, request_options: {}) ⇒ Privy::Models::Wallet

Some parameter documentations has been truncated, see Models::WalletGetWalletByAddressParams for more details.

Look up a wallet by its blockchain address. Returns the wallet object if found.

Parameters:

  • address (String)

    A blockchain wallet address. Ethereum addresses are normalized to EIP-55 checksu

  • include_archived (Boolean)

    Include archived wallets in lookup. Defaults to false (archived wallets return 4

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



446
447
448
449
450
451
452
453
454
455
# File 'lib/privy/resources/wallets.rb', line 446

def get_wallet_by_address(params)
  parsed, options = Privy::WalletGetWalletByAddressParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/wallets/address",
    body: parsed,
    model: Privy::Wallet,
    options: options
  )
end

#list(address: nil, authorization_key: nil, chain_type: nil, cursor: nil, external_id: nil, include_archived: nil, limit: nil, user_id: nil, request_options: {}) ⇒ Privy::Internal::Cursor<Privy::Models::Wallet>

Some parameter documentations has been truncated, see Models::WalletListParams for more details.

Get all wallets in your app.

Parameters:

  • address (String)

    A blockchain wallet address. Ethereum addresses are normalized to EIP-55 checksu

  • authorization_key (String)

    Filter wallets by authorization public key. Returns wallets owned by key quorums

  • chain_type (Symbol, Privy::Models::WalletChainType)

    The wallet chain types.

  • cursor (String)
  • external_id (String)

    Filter wallets by external ID.

  • include_archived (Boolean)

    Include archived wallets in lookup. Defaults to false.

  • limit (Float, nil)
  • user_id (String)

    Filter wallets by user ID. Cannot be used together with authorization_key.

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/privy/resources/wallets.rb', line 139

def list(params = {})
  parsed, options = Privy::WalletListParams.dump_request(params)
  query = Privy::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/wallets",
    query: query,
    page: Privy::Internal::Cursor,
    model: Privy::Wallet,
    options: options
  )
end

#raw_sign(wallet_id, params:, privy_authorization_signature: nil, privy_idempotency_key: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::RawSignResponse

Some parameter documentations has been truncated, see Models::WalletRawSignParams for more details.

Sign a message with a wallet by wallet ID.

Parameters:

  • wallet_id (String)

    Path param: ID of the wallet.

  • params (Privy::Models::RawSignHashParams, Privy::Models::RawSignBytesParams)

    Body param: Parameters for the raw_sign RPC.

  • privy_authorization_signature (String)

    Header param: Request authorization signature. If multiple signatures are requir

  • privy_idempotency_key (String)

    Header param: Idempotency keys ensure API requests are executed only once within

  • privy_request_expiry (String)

    Header param: Request expiry. Value is a Unix timestamp in milliseconds represen

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/privy/resources/wallets.rb', line 479

def raw_sign(wallet_id, params)
  parsed, options = Privy::WalletRawSignParams.dump_request(params)
  header_params =
    {
      privy_authorization_signature: "privy-authorization-signature",
      privy_idempotency_key: "privy-idempotency-key",
      privy_request_expiry: "privy-request-expiry"
    }
  @client.request(
    method: :post,
    path: ["v1/wallets/%1$s/raw_sign", wallet_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::RawSignResponse,
    options: options
  )
end

#rpc(wallet_id, wallet_rpc_request_body:, privy_authorization_signature: nil, privy_idempotency_key: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::EthereumPersonalSignRpcResponse, ...

Some parameter documentations has been truncated, see Models::WalletRpcParams for more details.

Sign a message or transaction with a wallet by wallet ID.

Parameters:

Returns:

See Also:



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/privy/resources/wallets.rb', line 519

def rpc(wallet_id, params)
  parsed, options = Privy::WalletRpcParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/wallets/%1$s/rpc", wallet_id],
    headers: parsed.except(:wallet_rpc_request_body).transform_keys(
      privy_authorization_signature: "privy-authorization-signature",
      privy_idempotency_key: "privy-idempotency-key",
      privy_request_expiry: "privy-request-expiry"
    ),
    body: parsed[:wallet_rpc_request_body],
    model: Privy::WalletRpcResponse,
    options: options
  )
end

#update(wallet_id, additional_signers: nil, display_name: nil, owner: nil, owner_id: nil, policy_ids: nil, privy_authorization_signature: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::Wallet

Some parameter documentations has been truncated, see Models::WalletUpdateParams for more details.

Update a wallet's policies or authorization key configuration.

Parameters:

  • wallet_id (String)

    Path param: ID of the wallet.

  • additional_signers (Array<Privy::Models::AdditionalSignerItemInput>)

    Body param: Additional signers for the wallet.

  • display_name (String, nil)

    Body param: A human-readable label for the wallet. Set to null to clear.

  • owner (Privy::Models::OwnerInputUser, Privy::Models::OwnerInputPublicKey, nil)

    Body param: The owner of the resource, specified as a Privy user ID, a P-256 pub

  • owner_id (String, nil)

    Body param: The key quorum ID to set as the owner of the resource. If you provid

  • policy_ids (Array<String>)

    Body param: New policy IDs to enforce on the wallet. Currently, only one policy

  • privy_authorization_signature (String)

    Header param: Request authorization signature. If multiple signatures are requir

  • privy_request_expiry (String)

    Header param: Request expiry. Value is a Unix timestamp in milliseconds represen

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/privy/resources/wallets.rb', line 94

def update(wallet_id, params = {})
  parsed, options = Privy::WalletUpdateParams.dump_request(params)
  header_params =
    {
      privy_authorization_signature: "privy-authorization-signature",
      privy_request_expiry: "privy-request-expiry"
    }
  @client.request(
    method: :patch,
    path: ["v1/wallets/%1$s", wallet_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::Wallet,
    options: options
  )
end