Using in Transactions
This guide demonstrates how to use the fee abstraction module with the cheqd SDK for both standard Cosmos SDK transactions and identity transactions (DIDs and DID-Linked Resources).
Fee abstraction allows users to pay transaction fees in alternative tokens (like IBC tokens from other chains) instead of the native CHEQ token, making the network more accessible to users from different ecosystems.
Prerequisites
Before using fee abstraction, ensure you have:
A funded wallet with the alternative token for fee payment
Access to a cheqd network with fee abstraction enabled
Understanding of the available host zones and supported tokens
Important: Your account must be funded with the bridged IBC representation of assets (e.g., transferred from Osmosis to cheqd) for fee abstraction to work
Note: Fee amounts in examples require manual conversion from CHEQ equivalent at current exchange rates. An upcoming SDK release will introduce USD fixed pricing and built-in price aggregation for automated fee calculation.
SDK Initialization with Fee Abstraction
import {
createCheqdSDK,
DIDModule,
ResourceModule,
FeeabstractionModule,
FeemarketModule,
CheqdNetwork,
AbstractCheqdSDKModule,
type ICheqdSDKOptions
} from '@cheqd/sdk';
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
async function initializeSDKWithFeeAbstraction() {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
'your twelve word mnemonic phrase goes here like this example',
{ prefix: 'cheqd' }
);
const options: ICheqdSDKOptions = {
modules: [
DIDModule as unknown as AbstractCheqdSDKModule,
ResourceModule as unknown as AbstractCheqdSDKModule,
FeeabstractionModule as unknown as AbstractCheqdSDKModule,
FeemarketModule as unknown as AbstractCheqdSDKModule
],
rpcUrl: 'https://rpc.cheqd.network',
network: CheqdNetwork.Testnet,
wallet: wallet
};
const sdk = await createCheqdSDK(options);
return { sdk, wallet };
}Standard Cosmos SDK Transactions
Token Transfer (Bank Module)
Staking Delegation
Claiming Rewards
Identity Transactions (DID and DLR)
DID Creation with Fee Abstraction
DID Update with Fee Abstraction
DID-Linked Resource Creation with Fee Abstraction
Image Resource Creation with Fee Abstraction
Fee Abstraction Management
Query Available Host Zones and Supported IBC Tokens
Complete Working Example
Here's a complete example that demonstrates the full workflow:
Best Practices
Fee Management
Token Selection: Choose widely accepted IBC tokens with good liquidity
Fee Estimation: Use dynamic fee calculation based on current market rates
Fallback Strategy: Always have native CHEQ tokens as a backup payment method
Cost Monitoring: Monitor fee costs across different tokens to optimize expenses
Transaction Optimization
Batch Operations: Group multiple messages to reduce fee overhead
Gas Estimation: Use accurate gas estimation to avoid overpaying
Retry Logic: Implement retry mechanisms for failed transactions
Fee Calculation: Use FeemarketModule for dynamic fee calculation
Security Considerations
Private Key Management: Securely store and handle private keys
Transaction Validation: Validate transaction parameters before signing
Network Selection: Use appropriate network (testnet for development)
Error Handling: Implement comprehensive error handling
Troubleshooting
Common Issues
Insufficient Funds: Ensure wallet has enough alternative tokens for fees
Invalid IBC Denom: Verify IBC denomination is correct for the target chain
Gas Estimation: Use appropriate gas limits for different transaction types
Host Zone Configuration: Ensure the alternative token's host zone is properly configured
Error Resolution
Next Steps
After implementing fee abstraction:
Monitor fee costs and optimize token selection
Implement automated fee strategy based on market conditions
Getting Help
If you encounter issues:
Check the cheqd SDK GitHub repository for updates
Review the fee abstraction module documentation
Join the cheqd Community Discord for support
Consult the Cosmos SDK documentation for standard transaction types
Last updated
Was this helpful?