@privy-io/react-auth
SDK to the latest version.
Next, configure your React app to:
'base_account'
to the config.appearance.walletList
array.config.embedded.ethereum.createOnLogin
to 'all-users'
.walletClientType: 'privy'
and walletClientType: 'base_account'
respectively in your useWallets
array:
wallet_getSubAccounts
RPC method. If the user does not have an existing Sub Account, create a new one for them using the wallet_addSubAccount
RPC:
useBaseAccountSdk
hook from Privy’s React SDK to access the instance of the Base Account SDK directly, and use the SDK’s subAccount.setToOwnerAccount
method to configure the embedded wallet to sign on behalf of the Sub Account’s operations.
As a parameter to this method, pass a function that returns a Promise
for a viem LocalAccount
representing the user’s embedded wallet. You can use Privy’s toViemAccount
utility method to do so.
personal_sign
: pass the Sub Account’s address, not the parent Base Account’s address, as the second parameter.eth_signTypedData_v4
: pass the Sub Account’s address, not the parent Base Account’s address, as the first parameter.eth_sendTransaction
: set from
in the transaction object to the Sub Account’s address, not the parent Base Account’s address.eth_sendTransaction
requests.