approve() and revoke() functions grant and remove delegate spending authority for compressed tokens. Only the token owner can perform these operations.
Before we approve or revoke delegates, we need:
- compressed token accounts to delegate or revoke delegation from, and
- an SPL mint with a token pool for compression. This token pool can be created for new SPL mints via
createMint()or added to existing SPL mints viacreateTokenPool().
Full Code Example
Prerequisites
Make sure you have dependencies and developer environment set up!Prerequisites & Setup
Prerequisites & Setup
DependenciesAlternatives:Developer EnvironmentBy default, this guide uses Localnet.Alternative: Using DevnetFollow these steps to create an RPC Connection. Replace
<your_api_key> with your API key before running.Get your API Key here, if you don’t have one yet.
Approve / Revoke Delegates
- Approve Delegate
- Approve and Revoke
Approve delegate authority for compressed tokens. The delegate can spend up to the approved amount.
approve-delegates.ts
Troubleshooting
Account is not delegated
Account is not delegated
Attempting to revoke non-delegated accounts.
Advanced Configuration
Approve Multiple Delegates
Approve Multiple Delegates
Revoke Multiple Delegates
Revoke Multiple Delegates