@lazysuperheroes/lazy-tokenswap-contracts
v2.1.0
Published
ABIs and TypeScript types for Lazy Token Swap smart contracts on Hedera
Downloads
42
Maintainers
Readme
@lazysuperheroes/lazy-tokenswap-contracts
ABIs and TypeScript types for the Lazy Token Swap smart contracts on Hedera Hashgraph.
Install
npm install @lazysuperheroes/lazy-tokenswap-contractsQuick Start
import { UnifiedTokenSwapABI } from '@lazysuperheroes/lazy-tokenswap-contracts';
import { ethers } from 'ethers';
// Create contract instance
const contract = new ethers.Contract(contractAddress, UnifiedTokenSwapABI, signer);
// Query swap configuration
const configs = await contract.getSwapConfigs([inputToken], [serial]);
// Execute swap (requires NFT + HBAR allowances)
const tx = await contract.swapNFTs([inputToken], [serial]);Exports
| Export | Description |
|--------|-------------|
| UnifiedTokenSwapABI | Multi-admin, multi-token swap with HBAR royalty defeat (recommended) |
| NoFallbackTokenSwapABI | Legacy swap without royalty handling |
| FallbackTokenSwapABI | Legacy swap with LAZY-based royalty bypass |
| BaseTokenSwapABI | Abstract base for legacy contracts |
| LazyGasStationABI | LAZY token distribution utility (legacy) |
| abis | Object containing all ABIs |
TypeScript
Full TypeChain-generated types are included:
import { UnifiedTokenSwap } from '@lazysuperheroes/lazy-tokenswap-contracts/types/UnifiedTokenSwap.sol';User Requirements for Swapping
Before calling swapNFTs, users need:
- Output token association - Associate the new NFT token with their account
- NFT allowance - Grant the contract
approveTokenNftAllowanceAllSerials(avoids Hedera's 100-allowance limit) - HBAR allowance - Grant 1 tinybar per swap to the contract (for royalty defeat, net cost = 0)
Note: Hedera limits accounts to ~100 allowance slots. The contract uses
setApprovalForAllfor graveyard approvals (once per token, not per serial) to stay within this limit. UsegetGraveyardApprovalCount()to monitor usage.
Links
License
GPL-3.0
