Appearance
Using the wallet
Ethereum wallets
To enable your app to request Ethereum signatures and transactions from the embedded wallet, Privy embedded wallets expose a EthereumEmbeddedWalletProvider
inspired by the EIP-1193 provider standard. 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 Ethereum embedded 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 specifiedmethod
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
}
// Replace this with your desired wallet, ensure it's an Ethereum wallet
guard let wallet = wallets.first, wallet.chainType == .ethereum else {
print("No Ethereum wallets available")
return
}
// Get the provider for wallet. Wallet chainType MUST be .ethereum
let provider = try privy.embeddedWallet.getEthereumProvider(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 Method | Supported? |
---|---|
personal_sign | ✅ |
eth_sign | ✅ |
eth_signTypedData_v4 | ✅ |
eth_signTransaction | ✅ |
eth_sendTransaction | ✅ |
eth_sendRawTransaction | ✅ |
Solana wallets
To enable your app to request Solana signatures and transactions from the embedded wallet, Privy embedded wallets expose a SolanaEmbeddedWalletProvider
. This allows you request signatures over messages and transactions from a user's Solana embedded wallet.
To request a signature, unwrap the Solana embedded wallet provider as shown below and call the signMessage
method on the provider with a base-64 encoded message to sign.
As an example, you might request a signature from the user's wallet like so:
swift
func signSolanaMessage() async throws {
guard case .connected(let wallets) = privy.embeddedWallet.embeddedWalletState else {
print("Wallet not connected")
return
}
// Replace this with your desired wallet, ensure it's a Solana wallet
guard let wallet = wallets.first, wallet.chainType == .solana else {
print("No Solana wallets available")
return
}
// Get the provider for wallet. Wallet chainType MUST be .solana
let provider = try privy.embeddedWallet.getSolanaProvider(for: wallet.address)
// Sign a Base64 encoded message
let signature = try await solanaProvider.signMessage(message: "SGVsbG8hIEkgYW0gdGhlIGJhc2U2NCBlbmNvZGVkIG1lc3NhZ2UgdG8gYmUgc2lnbmVkLg==")
}