Skip to content

Using the wallet

To enable your app to request signatures and transactions from the embedded wallet, Privy embedded wallets expose a provider inspired by the EIP-1193 provider standared. This allows you request signatures and transactions from the wallet via a familiar JSON-RPC API (e.g. personal_sign).

To make a request, unwrap the wallet provider as shown below and call its request method.

As a parameter to this method, to this method, pass an RpcRequest object that contains:

  • method: the name of the JSON-RPC method for the wallet to execute (e.g. 'personal_sign')
  • params: an array of parameters required by your specified method

As an example, you might request a signature from the user's wallet like so:

swift
func personalSign() async throws {
    guard case .connected(let wallets) = privy.embeddedWallet.embeddedWalletState else {
        print("Wallet not connected")
        return
    }

    guard let wallet = wallets.first else {
        print("No wallets available")
        return
    }

    // Get EIP1193 provider for wallet
    let provider = try privy.embeddedWallet.getProvider(for: wallet.address)

    // Replace `personal_sign` and the params with any supported JSON-RPC method
    let sigResponse = try await provider.request(
        RpcRequest(
            method: "personal_sign",
            params: ["This is the message that is being signed", wallet.address]
        )
    )

    let signature = sigResponse.response.data
}
Supported Ethereum JSON-RPC Methods

The following JSON-RPC methods are supported for the embedded wallet:

JSON-RPC MethodSupported?
personal_sign
eth_sign
eth_signTypedData_v4
eth_signTransaction
eth_sendTransaction
eth_sendRawTransaction