Smart Contract Details¶
UniVoucher is powered by a carefully designed smart contract that handles tangible gift card creation, redemption, and management. This page provides technical details about the contract's functionality and implementation.
Contract Overview¶
The UniVoucher contract is deployed on multiple EVM-compatible networks with the same functionality. It manages the entire lifecycle of tangible gift cards, from creation to redemption or cancellation.
Universal Contract Address
UniVoucher uses the same contract address across all supported networks: 0x51553818203e38ce0E78e4dA05C07ac779ec5b58
Contract Addresses¶
Network | Chain Prefix | Chain ID | Deployment Block | Verified Contract |
---|---|---|---|---|
Ethereum | 01 | 1 | 22714895 | View Code |
Base | 02 | 8453 | 31629302 | View Code |
BNB Chain | 03 | 56 | 51538912 | View Code |
Polygon | 04 | 137 | 72827473 | View Code |
Arbitrum | 05 | 42161 | 347855002 | View Code |
Optimism | 06 | 10 | 137227100 | View Code |
Avalanche | 07 | 43114 | 63937777 | View Code |
Core Contract Functions¶
Card Creation Functions¶
function depositETH(
address slotId,
uint256 amount,
string memory message,
string memory encryptedPrivateKey
) external payable
function depositERC20(
address slotId,
address tokenAddress,
uint256 amount,
string memory message,
string memory encryptedPrivateKey
) external
function bulkDepositETH(
address[] calldata slotIds,
uint256[] calldata amounts,
string[] calldata messages,
string[] calldata encryptedPrivateKeys
) external payable
function bulkDepositERC20(
address[] calldata slotIds,
address tokenAddress,
uint256[] calldata amounts,
string[] calldata messages,
string[] calldata encryptedPrivateKeys
) external
Card Redemption Function¶
function redeemCard(
string memory cardId,
address payable to,
bytes memory signature,
address payable partner
) external
Card Management Functions¶
Allows the creator to cancel an unredeemed card and reclaim funds. Cancels multiple cards in a single transaction.function getCardData(string memory cardId) external view returns (
bool active,
address tokenAddress,
uint256 tokenAmount,
uint256 feePaid,
address creator,
string memory message,
string memory encryptedPrivateKey,
address slotId,
uint256 timestamp,
address redeemedBy,
address cancelledBy,
address partnerAddress,
uint256 finalizedTimestamp
)
Utility Functions¶
Gets the card ID associated with a slot ID (public key). Checks if a card is still active (not redeemed or cancelled). Calculates the fee for a given amount based on the current fee percentage. Returns the current fee percentage in basis points (e.g., 100 = 1%).Contract Events¶
The contract emits the following events:
event CardCreated(
string cardId,
address indexed slotId,
address indexed creator,
address tokenAddress,
uint256 tokenAmount,
uint256 feePaid,
string message,
string encryptedPrivateKey,
uint256 timestamp
)
event CardRedeemed(
string cardId,
address indexed slotId,
address indexed to,
address tokenAddress,
uint256 amount,
address indexed partner,
uint256 timestamp
)
event CardCancelled(
string cardId,
address indexed slotId,
address indexed creator,
address tokenAddress,
uint256 amount,
uint256 timestamp
)
event FeesWithdrawn(
address indexed token,
address indexed recipient,
uint256 amount,
uint256 timestamp
)
Card Data Structure¶
Each card in the contract contains the following data:
- Card ID: Unique identifier generated with format version + chain prefix + slot ID
- Slot ID: The public key address used as the card's identifier
- Active Status: Whether the card can still be redeemed
- Token Address: The address of the token (address(0) for native tokens)
- Token Amount: The amount of tokens stored in the card
- Fee Paid: The fee amount collected during creation
- Creator: The address that created the card
- Message: An optional message stored with the card
- Encrypted Private Key: The encrypted private key that can be decrypted with the card secret
- Timestamp: When the card was created
- Redeemed By: Address that redeemed the card (if redeemed)
- Cancelled By: Address that cancelled the card (if cancelled)
- Partner Address: The partner address that received a fee during redemption (if any)
- Finalized Timestamp: When the card was redeemed or cancelled
Security Mechanism¶
The contract uses a cryptographic security model:
- Each card is associated with a public key (slot ID)
- The corresponding private key is encrypted and stored on-chain
- Only someone with the card secret can decrypt the private key
- To redeem, the private key signs a message proving knowledge of the secret
- The contract verifies this signature against the public key
- This proves the redeemer knows the secret without revealing it
Fee Collection¶
The contract collects fees during card creation and supports partner fees during redemption:
Creation Fees¶
- Fee is calculated as 1% of the card amount (100 basis points)
- Fees are stored in the contract, segregated by token
- Only the contract owner can withdraw accumulated fees
- Fee percentage can be adjusted by the contract owner
Partner Fees¶
- Partners can receive 1% of the card amount when facilitating redemptions
- Partner fee is deducted from the card amount
- Partner fees are paid directly to the partner address during redemption
- If no partner is specified, the full card amount goes to the recipient
Abandonment Protection¶
The contract includes a mechanism to handle abandoned cards:
- Cards unredeemed for 5 years are considered abandoned
- Only after this period can the contract owner intervene
- This prevents permanent fund loss while respecting user autonomy
Contract Verification¶
All deployed contracts are verified on their respective block explorers. You can view the source code, ABI, and contract details at the following links:
Verification Links¶
- Ethereum (ID: 1): https://etherscan.io/address/0x51553818203e38ce0E78e4dA05C07ac779ec5b58#code
- Base (ID: 8453): https://basescan.org/address/0x51553818203e38ce0E78e4dA05C07ac779ec5b58#code
- BNB Chain (ID: 56): https://bscscan.com/address/0x51553818203e38ce0E78e4dA05C07ac779ec5b58#code
- Polygon (ID: 137): https://polygonscan.com/address/0x51553818203e38ce0E78e4dA05C07ac779ec5b58#code
- Arbitrum (ID: 42161): https://arbiscan.io/address/0x51553818203e38ce0E78e4dA05C07ac779ec5b58#code
- Optimism (ID: 10): https://optimistic.etherscan.io/address/0x51553818203e38ce0E78e4dA05C07ac779ec5b58#code
- Avalanche (ID: 43114): https://snowtrace.io/address/0x51553818203e38ce0E78e4dA05C07ac779ec5b58#code
What You Can Find¶
- Source Code: Complete Solidity source code for transparency
- ABI: Application Binary Interface for direct contract interaction
- Compiler Details: Solidity version and optimization settings used
- Constructor Arguments: Parameters used during deployment
- Contract Bytecode: Compiled contract code deployed on-chain