RedemptionToken Contract

A standard ERC20 token that users receive when they redeem vouchers.

Overview

The RedemptionToken is a standard ERC20 token that represents the actual value or reward that users receive when they redeem their vouchers. Unlike the vouchers, redemption tokens are fully transferable and can be used within the ecosystem for purchases, access, or other benefits.

Contract Address:0x8f71a7503284c69eb200605b5ab11fabc555c865
Network:Sepolia Testnet

Key Features

Contract API

constructor

Initializes the token contract with a name, symbol, and initial owner.

Parameters:

  • _name - Token name
  • _symbol - Token symbol
  • _initialOwner - Initial owner address

mint

Mints new 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 tokens from the caller's account.

Parameters:

  • amount - Amount of tokens to burn

burnFrom

Burns tokens from a specified account (requires approval).

Parameters:

  • account - Account to burn from
  • amount - Amount of tokens to burn

Requirements:

The caller must have allowance for the account's tokens

addMinter

Adds a new address to the list of authorized minters.

Parameters:

  • minter - Address to add as a minter

Access Control:

Only callable by the contract owner

removeMinter

Removes an address from the list of authorized minters.

Parameters:

  • minter - Address to remove as a minter

Access Control:

Only callable by the contract owner

Code Examples

Checking Token Balance

JavaScript (ethers.js)
import { ethers } from "ethers";

// Connect to the contract
const tokenAddress = "0x8f71a7503284c69eb200605b5ab11fabc555c865";
const tokenABI = ["function balanceOf(address owner) view returns (uint256)"];
const provider = new ethers.providers.Web3Provider(window.ethereum);
const tokenContract = new ethers.Contract(tokenAddress, tokenABI, provider);

// Get the user's address
await provider.send("eth_requestAccounts", []);
const userAddress = await provider.getSigner().getAddress();

// Check the token balance
const balance = await tokenContract.balanceOf(userAddress);
console.log("Token Balance:", ethers.utils.formatUnits(balance, 18));

Transferring Tokens

JavaScript (ethers.js)
import { ethers } from "ethers";

// Connect to the contract
const tokenAddress = "0x8f71a7503284c69eb200605b5ab11fabc555c865";
const tokenABI = ["function transfer(address to, uint256 amount) returns (bool)"];
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const tokenContract = new ethers.Contract(tokenAddress, tokenABI, signer);

// Transfer tokens to another address
const recipientAddress = "0x..."; // Recipient address
const amount = ethers.utils.parseUnits("10", 18); // 10 tokens

try {
  const tx = await tokenContract.transfer(recipientAddress, amount);
  await tx.wait();
  console.log("Tokens transferred successfully!");
} catch (error) {
  console.error("Error transferring tokens:", error);
}

Security Considerations

Minting Control

The ability to mint new tokens is a powerful capability. Ensure that minter addresses are secure and that minting is properly controlled to prevent inflation.

Approval Risks

When approving tokens for spending by other contracts, be cautious about the amount approved. Consider using increaseAllowance and decreaseAllowance instead of approve when possible.

Previous: VoucherRedeemContractNext: Web Integration