Key Features
- Secure Transaction Signing: Signs ERC20 Approval transaction using Vincent Wallets within a secure Trusted Execution Environment
- Intelligent Allowance Checking: Automatically checks existing allowances to avoid unnecessary transactions
- Gas Balance Verification: Ensures the Vincent Wallet has some native tokens to pay for gas fees
How It Works
The ERC20 Approval Ability is built using the Vincent Ability SDK and operates in two phases:1
Precheck Phase
Validates the request and checks existing allowances:
- Verifies the user has a non-zero native token balance for gas fees
- Retrieves the current allowance for the specified spender and token
- Returns whether the requested amount is already approved, and what the current allowance is
2
Execution Phase
If needed, creates and submits the approval transaction:
- If the current allowance already matches the requested amount, returns success without creating a new transaction
- Otherwise, creates and signs an ERC20 approve transaction for the exact requested amount
- Returns the transaction hash and approval details
Getting Started
Depending on your role in the Vincent Ecosystem, you’ll be interacting with this Ability in different ways. Click on the link below that matches your role to see how to get started:- Vincent App Developers: If you’re building a Vincent App that needs to manage token approvals, go here.
- Vincent App Delegatees: If you’re executing this ability on behalf of Vincent App Users, go here.
Adding the Ability to your Vincent App
If you want to enable your App Delegatees to manage ERC20 token approvals on behalf of your Vincent App Users, you can add this Ability to your App. Adding Abilities to your Vincent App is done using the Vincent App Dashboard. Visit the Create Vincent App guide to learn more about how to add Abilities to your App during creation, or check out the Updating Your App guide to learn how to add Abilities to an existing App.Executing the Ability as a Vincent App Delegatee
Before executing an ERC20 approval, the following conditions must be met. You can use the Ability’sprecheck
function to check if these conditions are met, or you can check them manually.
- Gas Balance: The Vincent App User’s Vincent Wallet must have sufficient native tokens (ETH, MATIC, etc.) to pay for the approval transaction gas fees.
-
Valid Token Contract: The specified token address must be a valid ERC20 contract on the target network that implements the standard
approve
function. - Network Configuration: The RPC URL must be valid and accessible for the specified chain ID, and the network must support ERC20 token operations.
To learn more about executing Vincent Abilities, see the Executing Abilities guide.
Executing the precheck
Function
This Ability’s precheck
function is used to check if the Vincent Wallet has a non-zero native token balance for gas fees, and if the spender already has sufficient allowance for the requested amount.
- Parameters
- Implementation
- Response
Before executing the
precheck
function, you’ll need to provide the following parameters for the ERC20 token approval transaction:Executing the execute
Function
This Ability’s execute
function creates and submits the ERC20 approval transaction only if the current allowance is less than the requested amount.
- Parameters
- Implementation
- Response
The
execute
function expects the same parameters as the precheck
function:Important Considerations
Gas Requirements
Gas Requirements
The Vincent App User’s Vincent Wallet must have sufficient native tokens (ETH, MATIC, etc.) to pay for the approval transaction gas fees. The precheck function will verify this and return an error if the balance is insufficient.
Approval Amounts
Approval Amounts
- The ability approves the exact amount requested, not unlimited amounts
- If you need to change an existing approval, the new amount will replace the old one
- To revoke an approval, set the amount to 0
Network Configuration
Network Configuration
- Ensure the
rpcUrl
provided supports the specifiedchainId
- The ability works with any EVM-compatible network
Helper Functions
Available Helper Functions
Available Helper Functions
The ability package exports helper functions that can be used independently: