A non-transferable ERC20 token for season-based vouchers.
The TapAntsVoucher contract is a modified ERC20 token that prevents transfers between users, ensuring vouchers can only be redeemed through approved channels. It includes season-based identification and controlled burning mechanisms.
0x4223f47b1EB3bDB97d0117Ae50e2cC65309c22AE
Initializes the voucher contract with a name, symbol, season ID, and initial owner.
_name
- Token name_symbol
- Token symbol_seasonId
- Season identifier_initialOwner
- Initial owner addressSets the redemption contract address that is allowed to burn tokens.
_redeemContract
- Address of the redemption contractOnly callable by the contract owner
Mints new voucher tokens to a specified account.
to
- Recipient of the tokensamount
- Amount of tokens to mintOnly callable by the contract owner
Burns voucher tokens from a specified account during redemption.
from
- Account to burn fromamount
- Amount of tokens to burndata
- Additional data for the redemptionOnly callable by the contract owner or the redemption contract
Overridden to prevent transfers between users.
Always reverts with "Transfers are disabled for vouchers"
Overridden to prevent transfers between users.
Always reverts with "Transfers are disabled for vouchers"
Overridden to only allow approvals to the redemption contract.
spender
- Address to approveamount
- Amount of tokens to approveOnly allows approvals to the redemption contract or the contract itself
import { ethers } from "ethers";
// Connect to the contract
const voucherAddress = "0x4223f47b1EB3bDB97d0117Ae50e2cC65309c22AE";
const voucherABI = ["function balanceOf(address owner) view returns (uint256)"];
const provider = new ethers.providers.Web3Provider(window.ethereum);
const voucherContract = new ethers.Contract(voucherAddress, voucherABI, provider);
// Get the user's address
await provider.send("eth_requestAccounts", []);
const userAddress = await provider.getSigner().getAddress();
// Check the voucher balance
const balance = await voucherContract.balanceOf(userAddress);
console.log("Voucher Balance:", ethers.utils.formatUnits(balance, 18));
import { ethers } from "ethers";
// Connect to the contract
const voucherAddress = "0x4223f47b1EB3bDB97d0117Ae50e2cC65309c22AE";
const voucherABI = ["function mint(address to, uint256 amount)"];
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const voucherContract = new ethers.Contract(voucherAddress, voucherABI, signer);
// Mint vouchers to a recipient
const recipientAddress = "0x..."; // Recipient address
const amount = ethers.utils.parseUnits("100", 18); // 100 vouchers
try {
const tx = await voucherContract.mint(recipientAddress, amount);
await tx.wait();
console.log("Vouchers minted successfully!");
} catch (error) {
console.error("Error minting vouchers:", error);
}
The contract uses OpenZeppelin's Ownable pattern for access control. Ensure that the owner address is secure and consider implementing a multi-signature wallet or DAO for critical operations.
The redemption contract has the ability to burn vouchers. Ensure that this contract is properly audited and secured to prevent unauthorized redemptions.