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/balance.rb,
lib/privy/resources/wallets/transactions.rb,
lib/privy/resources/wallets/earn/ethereum.rb,
lib/privy/resources/wallets/earn/ethereum/incentive.rb

Direct Known Subclasses

Services::Wallets

Defined Under Namespace

Classes: Balance, Earn, 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:



465
466
467
468
469
470
# File 'lib/privy/resources/wallets.rb', line 465

def initialize(client:)
  @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)
end

Instance Attribute Details

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

Operations related to wallets



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

def balance
  @balance
end

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



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

def earn
  @earn
end

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

Operations related to wallets



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

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:



151
152
153
154
155
156
157
158
159
160
# File 'lib/privy/resources/wallets.rb', line 151

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:



188
189
190
191
192
193
194
195
196
197
# File 'lib/privy/resources/wallets.rb', line 188

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_type: nil, fee_configuration: nil, slippage_bps: nil, privy_authorization_signature: nil, privy_idempotency_key: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::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_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%).

  • 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:



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/privy/resources/wallets.rb', line 229

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::TransferActionResponse,
    options: options
  )
end

#authenticate_with_jwt(encryption_type:, recipient_public_key:, user_jwt:, request_options: {}) ⇒ Privy::Models::WalletAuthenticateWithJwtResponse::WithEncryption, Privy::Models::WalletAuthenticateWithJwtResponse::WithoutEncryption

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

Obtain a session key to enable wallet 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:



265
266
267
268
269
270
271
272
273
274
# File 'lib/privy/resources/wallets.rb', line 265

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:



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/privy/resources/wallets.rb', line 45

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_wallets_with_recovery(primary_signer:, recovery_user:, wallets:, request_options: {}) ⇒ Privy::Models::WalletCreateWalletsWithRecoveryResponse

Deprecated.

Create wallets with an associated recovery user.



290
291
292
293
294
295
296
297
298
299
# File 'lib/privy/resources/wallets.rb', line 290

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:



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/privy/resources/wallets.rb', line 325

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, request_options: {}) ⇒ Privy::Models::Wallet

Get a wallet by wallet ID.

Parameters:

  • wallet_id (String)

    ID of the wallet.

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

Returns:

See Also:



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

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

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

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

Parameters:

  • address (String)

    A blockchain wallet address (Ethereum or Solana).

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

Returns:

See Also:



373
374
375
376
377
378
379
380
381
382
# File 'lib/privy/resources/wallets.rb', line 373

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(authorization_key: nil, chain_type: nil, cursor: nil, external_id: 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:

  • 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.

  • 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:



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/privy/resources/wallets.rb', line 127

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:



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/privy/resources/wallets.rb', line 406

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:



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

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:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/privy/resources/wallets.rb', line 86

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