TapAntsVoucher Contract

A non-transferable ERC20 token for season-based vouchers.

Overview

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.

Contract Address:0x4223f47b1EB3bDB97d0117Ae50e2cC65309c22AE
Network:Sepolia Testnet
Current Season ID:1

Key Features

Contract API

constructor

Initializes the voucher contract with a name, symbol, season ID, and initial owner.

Parameters:

  • _name - Token name
  • _symbol - Token symbol
  • _seasonId - Season identifier
  • _initialOwner - Initial owner address

setRedeemContract

Sets the redemption contract address that is allowed to burn tokens.

Parameters:

  • _redeemContract - Address of the redemption contract

Access Control:

Only callable by the contract owner

mint

Mints new voucher tokens to a specified account.

Parameters:

  • to - Recipient of the tokens
  • amount - Amount of tokens to mint

Access Control:

Only callable by the contract owner

burn

Burns voucher tokens from a specified account during redemption.

Parameters:

  • from - Account to burn from
  • amount - Amount of tokens to burn
  • data - Additional data for the redemption

Access Control:

Only callable by the contract owner or the redemption contract

transfer

Overridden to prevent transfers between users.

Behavior:

Always reverts with "Transfers are disabled for vouchers"

transferFrom

Overridden to prevent transfers between users.

Behavior:

Always reverts with "Transfers are disabled for vouchers"

approve

Overridden to only allow approvals to the redemption contract.

Parameters:

  • spender - Address to approve
  • amount - Amount of tokens to approve

Behavior:

Only allows approvals to the redemption contract or the contract itself

Code Examples

Checking Voucher Balance

JavaScript (ethers.js)
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));

Minting Vouchers (Admin Only)

JavaScript (ethers.js)
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);
}

Security Considerations

Access Control

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.

Redemption Contract

The redemption contract has the ability to burn vouchers. Ensure that this contract is properly audited and secured to prevent unauthorized redemptions.

Previous: Technical OverviewNext: VoucherRedeemContract