Skip to content
ARCHITECTURE / 04 — Smart Contracts

Smart Contracts

The structure and design of the smart contracts

T&T’s smart contracts are written in Solidity and can be deployed to EVM-compatible chains. They are currently deployed on Polygon (Mainnet, Amoy), Astar (Astar, Shibuya), and Oasys (TCG Verse).

The role of the smart contracts in T&T is to implement the NFTs that serve as proof of participation in a world, and to manage the smart contracts that exist for each world.

Structure of the smart contracts

BaseNFT

BaseNFT is an NFT smart contract that implements ERC-721, based on the ERC-721Upgradeable implementation. It implements the following specifications.

  • ERC-4906 Communicates metadata updates on the blockchain
  • ERC-5192 Implements SBTs (Soulbound Tokens) that cannot be transferred to othersTransferability can be switched on and off

WorldFactory

As its name suggests, WorldFactory is used when generating a world. Its role is to generate the smart contracts, such as NFTs, used in the world.

MintManager

T&T can control NFT minting in various ways, and MintManager is responsible for this control. Its functions include creating Mint pages with a specified period and supply, and minting to a specified Ethereum account.

Performing this control at the smart contract level makes it possible to benefit from the security provided by the blockchain.

Access Control

T&T’s smart contracts are accessed by NFT owners, world administrators, the relay server, and others. To properly manage access from these different parties, each smart contract implements role-based access control according to the following rules, taking into account the balance between security and convenience.

  • World Owner: The world owner Has authority over the NFT smart contract
  • Administrator: T&T’s administrators and the relay server’s Ethereum account Have authority over WorldFactory and MintManager The NFT smart contracts can also be accessed from the Ethereum account used by the relay server. This is to ensure user convenience, for example by having T&T cover gas fees.

Upgradeable Smart Contracts Using the BeaconProxy Pattern

Smart contracts are immutable; that is, their implementation cannot be changed. However, situations frequently arise in which the implementation must be upgraded, such as when extending the NFT implementation or addressing security issues.

For this reason, T&T uses the BeaconProxy pattern to implement upgradeable smart contracts. This is a pattern that uses a single implementation to drive the behavior of multiple contracts.

T&T has many worlds, and trying to update the implementation of each contract individually when upgrading could incur enormous costs (gas fees and time). With the BeaconProxy pattern, updating a single implementation updates the behavior of multiple contracts, which reduces this cost.