Usage
How to use smart wallets in your React app
Openfort Kit uses wagmi internally and therefore it's possible to use hooks from wagmi to fetch data such as info about the connected account. Below there is an example of useAccount
wagmi hook in use.
Getting user address#
_10import { useAccount } from 'wagmi'_10_10const MyComponent = () => {_10 const { address } = useAccount()_10_10 return <div>Your address is: {address}</div>_10}
Openfort Smart Wallet#
When using the wallet provided by Openfort Embedded signer, you can sponsor gas fees, send batch transactions, use session keys, and more. Below is an example of how to use the wallet in your React app.
Sponsoring Transactions#
Openfort Smart Wallet allows you to sponsor gas fees for your users. Making it easier for them to interact with your app.
-
Create a gas policy on the Openfort Dashboard.
-
Set up the provider configuration with the embedded signer.
-
Set the
ethereumProviderPolicyId
in theembeddedSignerConfiguration
object. -
That's it! Your users will now have their gas fees sponsored.
More information about sponsoring gas fees can be found here.
Sending Batch Transactions#
Openfort Smart Wallet support sending a batch of transactions in a single, atomic submission to the network.
Library | Method |
---|---|
Wagmi | Use the useWriteContracts hook. |
Viem | sendCalls action |
Using Session Keys#
Session keys are programmable access tokens with specific permissions, designed for controlled interactions. Examples include:
- Granting access to specific areas or features.
- Limiting usage to a set amount of resources (e.g., 1000 units of currency).
- Time-bound validity (e.g., expiring after 3 days). Permissions can be combined, enabling fine-tuned, context-specific capabilities.
Session Keys streamline interactions by:
- Seamless Interactions: Reducing the need for repeated confirmations by delegating specific permissions to locally stored keys, enhancing user experience.
- Automated Processes: Enabling automation through server-bound keys with defined permissions for tasks like recurring actions, resource management, or condition-based triggers.
Library | Method |
---|---|
Viem | Use the wallet_grantPermissions action |
Using another wallet#
If you are using another wallet you will need to check if they have your desired functionality.
Library | Method |
---|---|
Wagmi | Use the getCapabilities hook. |
Viem | getCapabilities action |