Additional

This document is better viewed at https://docs.broxus.com/tip3

Additional contracts that can be used in conjunction with the TokenRoot and TokenWallet contract include:

Selector: the contract, defined in the TIP-6.1 standard, provides a method for determining the interfaces implemented by a smart contract on the TVM-like networks. It uses the XOR of all function selectors in the interface as the identifier for the interface. This allows for querying if a contract supports a specific interface and adapting the way it is interacted with.

TokenFactory: The TokenFactory contract is used to create new instances of the TokenRoot contract. It allows for easily creating new TIP-3 compliant tokens. It can be configured to use different implementations of the TokenRoot, such as the TokenRootBurnableByRootBase or TokenRootBurnPausableBase, to add additional functionality to the new tokens.

The use of these contracts allows for more flexibility and functionality in the management and creation of TIP-3 compliant tokens, and can be integrated into the overall token management system for an application or platform built on a blockchain.

TokenFactory

ITokenFactory

import "@broxus-ton-tokens-contracts/contracts/additional/ITokenFactory.sol";

This interface defines a deployRoot function that creates a new token root contract.

deployRoot(string name, string symbol, uint8 decimals, address owner, address initialSupplyTo, uint128 initialSupply, uint128 deployWalletValue, bool mintDisabled, bool burnByRootDisabled, bool burnPaused, address remainingGasTo, bool upgradeable) → address external

Creates a new token root contract

TokenFactory

import "@broxus-ton-tokens-contracts/contracts/additional/TokenFactory.sol";

This contract is used to create new TokenRoot and TokenRootUpgradeable.

onlyOwner() modifier

Modifier than throws if called by any account other than the owner_.

cashBack() modifier

Modifier that returns all remaining gas to the caller.

constructor(address owner, uint128 deployValue, TvmCell rootCode, TvmCell walletCode, TvmCell rootUpgradeableCode, TvmCell walletUpgradeableCode, TvmCell platformCode) public

This is the constructor for the token factory contract, which is used to deploy token root contracts.

deployRoot(string name, string symbol, uint8 decimals, address owner, address initialSupplyTo, uint128 initialSupply, uint128 deployWalletValue, bool mintDisabled, bool burnByRootDisabled, bool burnPaused, address remainingGasTo, bool upgradeable) → address external

_buildCommonStateInit(uint256 nonce, string name, string symbol, uint8 decimals, address owner) → TvmCell internal

Builds a StateInit for the common TokenRoot contract.

_buildUpgradeableStateInit(uint256 nonce, string name, string symbol, uint8 decimals, address owner) → TvmCell internal

Builds a StateInit for the TokenRootUpgradeable contract.

changeDeployValue(uint128 deployValue) public

Changes the value to be sent to the root contract when deploying a new token root.

changeRootCode(TvmCell rootCode) public

Changes the rootCode.

changeWalletCode(TvmCell walletCode) public

Changes the code of the TokenWallet contract, which is used to deploy new wallets.

changeRootUpgradeableCode(TvmCell rootUpgradeableCode) public

Changes the code of the TokenRootUpgradeable contract, which is used to deploy new token roots.

changeWalletUpgradeableCode(TvmCell walletUpgradeableCode) public

Changes the code of the TokenWalletUpgradeable contract, which is used to deploy new token roots.

changePlatformCode(TvmCell platformCode) public

Changes the code of the TokenWalletPlatform contract, which is used to deploy new token roots.

transferOwner(address owner) public

Changes the owner of the factory.

It’s two-step process: first, the new pending owner is set, then the pending owner can accept the ownership.

acceptOwner() public

Accepts the ownership of the factory.

It’s two-step process: first, the new pending owner is set, then the pending owner can accept the ownership.

Precondition:

  • Sender should be the pending owner.

  • Pending owner should not be zero.

Postcondition:

  • _owner is changed to _pendingOwner.

  • _pendingOwner is changed to zero.

upgrade(TvmCell code) public

Upgrades the factory code to a new version.

Standard Interface Detection

SID

import "@broxus-ton-tokens-contracts/contracts/additional/SID.sol";

The SID interface is part of the TIP6.1 standard, as defined in the Everscale Network documentation. It defines a smart contract interface that allows other contracts to query if a contract implements a specific interface.

Implementers can declare support of contract interfaces, which can then be queried by others Selector.

For an implementation, see:

supportsInterface(bytes4 interfaceID) → bool external

Returns a bool value that indicates whether the contract implements the specified interfaceID.

Selector

import "@broxus-ton-tokens-contracts/contracts/additional/Selector.sol";

constructor() public

calculateAcceptTransferSelector() → bytes4 public

Calculate an interface identifier for acceptTransfer method.

calculateAcceptMintSelector() → bytes4 public

Calculate an interface identifier for acceptMint method.

calculateAcceptBurnSelector() → bytes4 public

Calculate an interface identifier for acceptBurn method.

calculateTIP3TokenRootInterfaceID() → bytes4 public

Calculate an interface identifiers for name, symbol, decimals, totalSupply, walletCode, and acceptBurn methods.

calculateTIP3TokenWalletInterfaceID() → bytes4 public

Calculate an interface identifiers for root, balance, walletCode, acceptTransfer, and `acceptMint`methods.

calculateSIDInterfaceID() → bytes4 public

Calculate an interface identifier for supportsInterface method.

calculateVersionedInterfaceID() → bytes4 public

Calculate an interface identifier for version method.

calculateTokenRootInterfaceID() → bytes4 public

Calculate an interface identifiers for rootOwner, walletOf, mint, deployWallet methods.

calculateTokenWalletInterfaceID() → bytes4 public

Calculate an interface identifiers for owner, transfer, and transferToWallet methods.

calculateBurnableTokenWalletInterfaceID() → bytes4 public

Calculate an interface identifier for burn method.

calculateBurnableByRootTokenRootInterfaceID() → bytes4 public

Calculate an interface identifiers for burnTokens, disableBurnByRoot, and burnByRootDisabled methods.

calculateBurnableByRootTokenWalletInterfaceID() → bytes4 public

Calculate an interface identifier for burnByRoot method.

calculateDestroyableInterfaceID() → bytes4 public

Calculate an interface identifier for destroy method.

calculateDisableableMintTokenRootInterfaceID() → bytes4 public

Calculate an interface identifiers for disableMint and mintDisabled methods.

calculateTransferableOwnershipInterfaceID() → bytes4 public

Calculate an interface identifier for transferOwnership method.

calculateBurnPausableTokenRootInterfaceID() → bytes4 public

Calculate an interface identifiers for setBurnPaused and burnPaused methods.

calculateTokenWalletUpgradeableInterfaceID() → bytes4 public

Calculate an interface identifiers for upgrade, acceptUpgrade and platformCode methods.

calculateTokenRootUpgradeableInterfaceID() → bytes4 public

Calculate an interface identifiers for walletVersion, platformCode, requestUpgradeWallet, setWalletCode and upgrade methods.