Skip to content

Solidity API

TradeToken3643

TradeTokenType

solidity
enum TradeTokenType {
  Mintable,
  Wrappable
}

tradeTokenType

solidity
enum TradeToken3643.TradeTokenType tradeTokenType

The type of this TradeToken instance

This variable stores the type of the TradeToken, which can be either Mintable or Wrappable, defined by the TradeTokenType enum.

forcedUnwrapSignatureCounter

solidity
uint256 forcedUnwrapSignatureCounter

Counter used for unique forcedunwrap signatures

attachments

solidity
mapping(string => address) attachments

Mapping to track IPFS Content Identifiers (CIDs) and their submitters

This mapping associates each CID string to the address that submitted it.

AttachmentAdded

solidity
event AttachmentAdded(string cid, address submitter)

Emitted when a new attachment is added to the contract

This event is triggered when a new attachment is submitted and stored in the contract. It records the CID of the attachment and the address of the submitter.

Parameters

NameTypeDescription
cidstringThe IPFS Content Identifier of the attachment
submitteraddressThe address that submitted the attachment

WrapRatioAdded

solidity
event WrapRatioAdded(address childTradeTokenAddress, uint256 ratio)

Emitted when a new wrap ratio is added for a child Trade Token

This event is emitted when a new wrap ratio is set for a child Trade Token. The ratio is scaled by 10^18 for precise calculations.

Parameters

NameTypeDescription
childTradeTokenAddressaddressThe address of the child Trade Token
ratiouint256The wrap ratio scaled by 10^18

WrapRatioReceived

solidity
event WrapRatioReceived(address tradeTokenAddress, uint256 ratio)

Emitted when a wrap ratio is received from another Trade Token

This event is emitted when a Trade Token receives a wrap ratio from another Trade Token. It helps track changes in wrap ratios.

Parameters

NameTypeDescription
tradeTokenAddressaddressThe address of the Trade Token setting the ratio
ratiouint256The received wrap ratio

TradeTokenMintingNotAllowed

solidity
error TradeTokenMintingNotAllowed()

Thrown when minting is not allowed for the TradeToken.

This error is triggered when minting operations are attempted, but the contract is not in a state that allows new tokens to be minted.

TradeTokenUnauthorizedTradeTokenOwner

solidity
error TradeTokenUnauthorizedTradeTokenOwner(address target)

Thrown when the caller is not the authorized owner of the TradeToken.

This error is thrown when a caller attempts to set or modify aspects of a TradeToken they do not own.

Parameters

NameTypeDescription
targetaddressAddress of the target TradeToken that caused the error.

TradeTokenInvalidTwinContract

solidity
error TradeTokenInvalidTwinContract(address target)

Thrown when the target contract does not have identical bytecode.

This error is thrown when a contract tries to interact with a non-twin TradeToken, meaning their bytecode does not match.

Parameters

NameTypeDescription
targetaddressAddress of the contract that failed the bytecode verification.

TradeTokenWrapRatioNotRegistered

solidity
error TradeTokenWrapRatioNotRegistered(address target)

Thrown when the wrap ratio is not registered for the target TradeToken.

This error is thrown when a wrap operation is attempted, but the ratio is not registered for the specified TradeToken.

Parameters

NameTypeDescription
targetaddressAddress of the target TradeToken for which the wrap ratio is missing.

TradeTokenWrapRatioAlreadyExists

solidity
error TradeTokenWrapRatioAlreadyExists(address target)

Thrown when the wrap ratio has already been set for the target TradeToken.

This error occurs when attempting to register a wrap ratio that already exists for the given TradeToken.

Parameters

NameTypeDescription
targetaddressAddress of the target TradeToken where the wrap ratio is already set.

TradeTokenInsufficientBalanceForWrap

solidity
error TradeTokenInsufficientBalanceForWrap(uint256 available, uint256 required)

Thrown when the user does not have enough balance to wrap the tokens.

This error is thrown when a user tries to wrap more tokens than they hold in their balance.

Parameters

NameTypeDescription
availableuint256The amount of tokens available in the user's balance.
requireduint256The amount of tokens required to complete the wrap operation.

TradeTokenTransferFailed

solidity
error TradeTokenTransferFailed(address to, uint256 value)

Thrown when the transfer of tokens has failed.

This error is raised when a token transfer to the specified address fails.

Parameters

NameTypeDescription
toaddressAddress to which the transfer was intended.
valueuint256The value of tokens that failed to be transferred.

TradeTokenAttachmentAlreadyAdded

solidity
error TradeTokenAttachmentAlreadyAdded(string cid)

Thrown when the attachment with the given CID has already been added.

This error occurs when a duplicate attachment with the same CID is added.

Parameters

NameTypeDescription
cidstringThe IPFS Content Identifier that has been already registered.

TradeTokenAlreadyInitialized

solidity
error TradeTokenAlreadyInitialized()

Thrown when the TradeToken has already been initialized.

This error is triggered when an attempt is made to initialize the TradeToken after it has already been initialized.

TradeTokenInvalidAddress

solidity
error TradeTokenInvalidAddress(address invalidAddress)

Thrown when the address provided is invalid.

This error occurs when an invalid address is passed to a function requiring a valid address.

Parameters

NameTypeDescription
invalidAddressaddressThe invalid address that caused the error.

TradeTokenInvalidStringArgument

solidity
error TradeTokenInvalidStringArgument(string invalidArgument)

Thrown when the string argument provided is invalid.

This error is thrown when a function receives an invalid string argument, such as an empty string or incorrect format.

Parameters

NameTypeDescription
invalidArgumentstringThe invalid string argument that caused the error.

TradeTokenInvalidDecimals

solidity
error TradeTokenInvalidDecimals(uint8 invalidDecimals)

Thrown when the number of decimals provided for the TradeToken is invalid.

This error occurs when the number of decimals provided for the TradeToken is not valid (e.g., it exceeds the allowed limit).

Parameters

NameTypeDescription
invalidDecimalsuint8The invalid decimals value provided.

TradeTokenTransferNotAllowed

solidity
error TradeTokenTransferNotAllowed()

Thrown when token transfers are not allowed at the moment.

This error occurs when a transfer operation is attempted while transfers are restricted or paused.

TradeTokenNoTokensToRecover

solidity
error TradeTokenNoTokensToRecover(address walletAddress)

Thrown when there are no tokens to recover for the provided wallet address.

This error is thrown when attempting to recover tokens from a wallet address with no tokens.

Parameters

NameTypeDescription
walletAddressaddressThe wallet address for which token recovery failed.

TradeTokenRecoveryKeyMissing

solidity
error TradeTokenRecoveryKeyMissing()

Thrown when the recovery key is missing for the TradeToken recovery operation.

This error is raised when a recovery operation is attempted, but the necessary recovery key is not provided.

TradeTokenWalletFrozen

solidity
error TradeTokenWalletFrozen(address walletAddress)

Thrown when the wallet is frozen, preventing further operations.

This error occurs when a wallet address has been frozen and can no longer perform transactions until unfrozen.

Parameters

NameTypeDescription
walletAddressaddressThe wallet address that is frozen.

TradeTokenInsufficientBalance

solidity
error TradeTokenInsufficientBalance(uint256 available, uint256 required)

Thrown when the user has insufficient balance to proceed with a transaction.

This error is thrown when a user attempts a transaction without sufficient balance.

Parameters

NameTypeDescription
availableuint256The amount of tokens available in the user's balance.
requireduint256The amount of tokens required for the operation.

TransferNotPossible

solidity
error TransferNotPossible()

Thrown when the transfer is not possible due to other conditions.

This error occurs when a transfer operation cannot proceed due to various conditions such as compliance violations or other restrictions.

TradeTokenPaused

solidity
error TradeTokenPaused()

Thrown when the TradeToken is currently paused and cannot perform actions.

This error occurs when an action is attempted on a TradeToken that is paused, typically for maintenance or emergency reasons.

TradeTokenNotPaused

solidity
error TradeTokenNotPaused()

Thrown when the TradeToken is not paused, but an action requiring it to be paused is being attempted.

This error is thrown when a function requires the contract to be paused, but it is not currently in that state.

TradeTokenIdentityNotVerified

solidity
error TradeTokenIdentityNotVerified(address account)

Thrown when the identity of the account is not verified.

This error occurs when a transaction is attempted by an account that has not been verified by the contract's identity registry.

Parameters

NameTypeDescription
accountaddressThe address of the account whose identity is not verified.

TradeTokenComplianceViolation

solidity
error TradeTokenComplianceViolation(address from, address to, uint256 amount)

Thrown when a compliance violation occurred during a transaction.

This error is raised when a transaction violates compliance rules, such as when certain transfers are not allowed by the compliance system.

Parameters

NameTypeDescription
fromaddressAddress of the sender involved in the violation.
toaddressAddress of the recipient involved in the violation.
amountuint256The amount involved in the compliance violation.

whenNotPaused

solidity
modifier whenNotPaused()

Modifier to make a function callable only when the contract is not paused.

_This modifier checks the _tokenPaused variable and Reverted if the contract is paused.

Errors:

  • TradeTokenPaused: Reverted when trying to execute a function while the contract is paused._

whenPaused

solidity
modifier whenPaused()

Modifier to make a function callable only when the contract is paused.

_This modifier checks the _tokenPaused variable and Reverted if the contract is not paused.

Errors:

  • TradeTokenNotPaused: Reverted when trying to execute a function while the contract is not paused._

constructor

solidity
constructor(enum TradeToken3643.TradeTokenType _tradeTokenType) public

Sets up the Trade Token with the specified type.

_This constructor initializes the tradeTokenType state variable based on the provided argument.

Requirements:

  • A valid TradeTokenType must be provided (either Mintable or Wrappable)._

Parameters

NameTypeDescription
_tradeTokenTypeenum TradeToken3643.TradeTokenTypeThe type of the Trade Token (Mintable or Wrappable).

init

solidity
function init(address _identityRegistry, address _compliance, string _name, string _symbol, uint8 _decimals, address _onchainID) external

Initializes the Trade Token contract with essential details.

_This function sets up the token contract, including the identity registry, compliance contract, and other token properties.

Requirements:

  • The contract must not be initialized already (i.e., owner() must be address(0)).
  • Both _identityRegistry and _compliance addresses must be valid (not the zero address).
  • _name and _symbol must not be empty strings.
  • _decimals must not exceed 18._

Parameters

NameTypeDescription
_identityRegistryaddressThe address of the Identity registry linked to the token.
_complianceaddressThe address of the compliance contract linked to the token.
_namestringThe name of the token.
_symbolstringThe symbol of the token.
_decimalsuint8The number of decimals for the token.
_onchainIDaddressThe address of the on-chain ID of the token (can be zero address if not set). Errors: - TradeTokenAlreadyInitialized: Reverted when trying to initialize the contract after it has already been initialized. - TradeTokenInvalidAddress: Reverted if either _identityRegistry or _compliance is the zero address. - TradeTokenInvalidStringArgument: Reverted if either _name or _symbol is an empty string. - TradeTokenInvalidDecimals: Reverted if _decimals exceeds 18. Emits: - UpdatedTokenInformation: Emitted when the token's basic information is updated. - IdentityRegistryAdded: Emitted when the identity registry address is set. - ComplianceAdded: Emitted when the compliance contract address is set.

approve

solidity
function approve(address _spender, uint256 _amount) external virtual returns (bool)

Allows the owner of the token to approve a spender to spend a specified amount of tokens.

This function calls the internal _approve function to set the spender's allowance.

Parameters

NameTypeDescription
_spenderaddressThe address of the spender who will be approved.
_amountuint256The amount of tokens that the spender is allowed to spend.

increaseAllowance

solidity
function increaseAllowance(address _spender, uint256 _addedValue) external virtual returns (bool)

Increases the allowance of a spender to spend additional tokens on behalf of the caller.

_This function updates the spender's allowance by adding the specified value to the existing allowance.

Requirements:

  • The caller must have an existing allowance set for the spender._

Parameters

NameTypeDescription
_spenderaddressThe address of the spender whose allowance will be increased.
_addedValueuint256The amount by which the allowance will be increased.

decreaseAllowance

solidity
function decreaseAllowance(address _spender, uint256 _subtractedValue) external virtual returns (bool)

Decreases the allowance of a spender to spend tokens on behalf of the caller.

_This function updates the spender's allowance by subtracting the specified value from the existing allowance.

Requirements:

  • The caller must have an existing allowance set for the spender._

Parameters

NameTypeDescription
_spenderaddressThe address of the spender whose allowance will be decreased.
_subtractedValueuint256The amount by which the allowance will be decreased.

setName

solidity
function setName(string _name) external

Allows the owner to set a new name for the token.

_This function updates the token's name.

Requirements:

  • The caller must be the owner of the contract.
  • The new name must not be an empty string._

Parameters

NameTypeDescription
_namestringThe new name for the token. Errors: - TradeTokenInvalidStringArgument: Reverted if the provided name is an empty string. Emits: - UpdatedTokenInformation: Emitted when the token name is successfully updated.

setSymbol

solidity
function setSymbol(string _symbol) external

Allows the owner to set a new symbol for the token.

_This function updates the token's symbol.

Requirements:

  • The caller must be the owner of the contract.
  • The new symbol must not be an empty string._

Parameters

NameTypeDescription
_symbolstringThe new symbol for the token. Errors: - TradeTokenInvalidStringArgument: Reverted if the provided symbol is an empty string. Emits: - UpdatedTokenInformation: Emitted when the token symbol is successfully updated.

setOnchainID

solidity
function setOnchainID(address _onchainID) external

Allows the owner to set a new Onchain ID for the token.

_This function updates the token's Onchain ID. If the provided address is the zero address, no Onchain ID is bound to the token.

Requirements:

  • The caller must be the owner of the contract._

Parameters

NameTypeDescription
_onchainIDaddressThe new Onchain ID for the token. If set to the zero address, no Onchain ID is associated. Emits: - UpdatedTokenInformation: Emitted when the token's Onchain ID is successfully updated.

pause

solidity
function pause() external

Pauses the token contract, preventing any further actions on the token.

_This function sets the token's paused state to true.

Requirements:

  • The caller must be an agent with permission to pause the contract.
  • The contract must not already be paused.

Emits:

  • Paused: Emitted when the token contract is paused._

unpause

solidity
function unpause() external

Unpauses the token contract, allowing actions to be performed again.

_This function sets the token's paused state to false and emits an Unpaused event.

Requirements:

  • The caller must be an agent with permission to unpause the contract.
  • The contract must be paused.

Emits:

  • Unpaused: Emitted when the token contract is unpaused._

batchTransfer

solidity
function batchTransfer(address[] _toList, uint256[] _amounts) external

Allows the sender to batch transfer tokens to multiple recipients.

_This function performs multiple transfers in a single transaction by iterating through the provided list of addresses and amounts.

Requirements:

  • The length of _toList and _amounts must be the same.
  • The sender must have enough tokens for each transfer._

Parameters

NameTypeDescription
_toListaddress[]List of recipient addresses.
_amountsuint256[]List of amounts to transfer, corresponding to each recipient.

transferFrom

solidity
function transferFrom(address _from, address _to, uint256 _amount) external returns (bool)

Facilitates the transfer of tokens from one address to another while ensuring compliance and security checks.

_This function overrides the standard ERC-20 transferFrom to include additional logic for trade validity.

Requirements:

  • The contract must not be paused.
  • The sender and receiver addresses must not be frozen.
  • The receiver address must be verified by the identity registry._

Parameters

NameTypeDescription
_fromaddressThe address of the sender.
_toaddressThe address of the receiver.
_amountuint256The number of tokens to transfer.

Return Values

NameTypeDescription
[0]booltrue if the transfer is successful. Errors: - TradeTokenWalletFrozen: Reverted if the sender or receiver address is frozen. - TradeTokenInsufficientBalance: Reverted if the sender has insufficient unfrozen balance. - TradeTokenTransferNotAllowed: Reverted if the receiver is not verified or the transfer violates compliance rules. Emits: - Transfer: Emitted when the tokens are successfully transferred.

batchForcedTransfer

solidity
function batchForcedTransfer(address[] _fromList, address[] _toList, uint256[] _amounts) external

Executes forced transfers of tokens for multiple accounts in a single transaction.

_Calls the forcedTransfer function for each entry in the provided lists.

Requirements:

  • _fromList, _toList, and _amounts must have the same length._

Parameters

NameTypeDescription
_fromListaddress[]The list of addresses to transfer tokens from.
_toListaddress[]The list of addresses to transfer tokens to.
_amountsuint256[]The list of token amounts to transfer for each pair.

batchMint

solidity
function batchMint(address[] _toList, uint256[] _amounts) external

Mints tokens for multiple accounts in a single transaction.

_Calls the mint function for each entry in the provided lists.

Requirements:

  • _toList and _amounts must have the same length._

Parameters

NameTypeDescription
_toListaddress[]The list of addresses to mint tokens to.
_amountsuint256[]The list of token amounts to mint for each address.

batchBurn

solidity
function batchBurn(address[] _userAddresses, uint256[] _amounts) external

Burns tokens for multiple accounts in a single transaction.

_Calls the burn function for each entry in the provided lists.

Requirements:

  • _userAddresses and _amounts must have the same length._

Parameters

NameTypeDescription
_userAddressesaddress[]The list of addresses whose tokens will be burned.
_amountsuint256[]The list of token amounts to burn for each address.

batchSetAddressFrozen

solidity
function batchSetAddressFrozen(address[] _userAddresses, bool[] _freeze) external

Freezes or unfreezes multiple addresses in a single transaction.

_Calls the setAddressFrozen function for each address with the corresponding freeze status.

Requirements:

  • _userAddresses and _freeze must have the same length._

Parameters

NameTypeDescription
_userAddressesaddress[]The list of addresses to freeze or unfreeze.
_freezebool[]The list of boolean values indicating the freeze status for each address.

batchFreezePartialTokens

solidity
function batchFreezePartialTokens(address[] _userAddresses, uint256[] _amounts) external

Freezes a specified amount of tokens for multiple addresses.

_Calls the freezePartialTokens function for each address with the corresponding amount.

Requirements:

  • _userAddresses and _amounts must have the same length._

Parameters

NameTypeDescription
_userAddressesaddress[]The list of addresses whose tokens will be partially frozen.
_amountsuint256[]The list of token amounts to freeze for each address.

batchUnfreezePartialTokens

solidity
function batchUnfreezePartialTokens(address[] _userAddresses, uint256[] _amounts) external

Unfreezes a specified amount of tokens for multiple addresses.

_Calls the unfreezePartialTokens function for each address with the corresponding amount.

Requirements:

  • _userAddresses and _amounts must have the same length._

Parameters

NameTypeDescription
_userAddressesaddress[]The list of addresses whose tokens will be partially unfrozen.
_amountsuint256[]The list of token amounts to unfreeze for each address.

recoveryAddress

solidity
function recoveryAddress(address _lostWallet, address _newWallet, address _investorOnchainID) external returns (bool)

Facilitates the recovery of a lost wallet by transferring its tokens and associated settings to a new wallet.

_This function transfers the balance, frozen tokens, and identity information of the lost wallet to a new wallet.

Requirements:

  • The _lostWallet must have a non-zero token balance.
  • The _newWallet must be linked to the provided _investorOnchainID through a valid recovery key.
  • The caller must be an agent with permission to recover a wallet._

Parameters

NameTypeDescription
_lostWalletaddressThe address of the wallet whose tokens and settings are to be recovered.
_newWalletaddressThe address of the wallet that will receive the tokens and settings.
_investorOnchainIDaddressThe on-chain identity linked to the investor for verification purposes. Errors: - TradeTokenNoTokensToRecover: Reverted if the _lostWallet has no tokens to recover. - TradeTokenRecoveryKeyMissing: Reverted if the _newWallet is not linked to _investorOnchainID with a valid recovery key. Emits: - RecoverySuccess: Emitted when the recovery process is completed successfully.

totalSupply

solidity
function totalSupply() external view returns (uint256)

Retrieves the total supply of tokens in existence.

This function returns the total number of tokens currently minted.

Return Values

NameTypeDescription
[0]uint256The total supply of tokens.

allowance

solidity
function allowance(address _owner, address _spender) external view virtual returns (uint256)

Checks the allowance granted to a spender by an owner.

This function returns the amount of tokens the _spender is allowed to use on behalf of _owner.

Parameters

NameTypeDescription
_owneraddressThe address of the token owner.
_spenderaddressThe address of the spender.

Return Values

NameTypeDescription
[0]uint256The amount of tokens the spender can use.

identityRegistry

solidity
function identityRegistry() external view returns (contract IIdentityRegistry)

Provides access to the identity registry contract used by the token.

This function returns the address of the identity registry contract.

Return Values

NameTypeDescription
[0]contract IIdentityRegistryThe IIdentityRegistry contract associated with the token.

compliance

solidity
function compliance() external view returns (contract IModularCompliance)

Provides access to the compliance contract used by the token.

This function returns the address of the compliance module managing token transfers.

Return Values

NameTypeDescription
[0]contract IModularComplianceThe IModularCompliance contract associated with the token.

paused

solidity
function paused() external view returns (bool)

Checks whether the token contract is currently paused.

This function returns the pause status of the token contract.

Return Values

NameTypeDescription
[0]booltrue if the token contract is paused, otherwise false.

isFrozen

solidity
function isFrozen(address _userAddress) external view returns (bool)

Checks whether a specific address is currently frozen.

This function returns the frozen status of the given _userAddress.

Parameters

NameTypeDescription
_userAddressaddressThe address to check for the frozen status.

Return Values

NameTypeDescription
[0]booltrue if the address is frozen, otherwise false.

getFrozenTokens

solidity
function getFrozenTokens(address _userAddress) external view returns (uint256)

Retrieves the amount of tokens that are frozen for a specific address.

This function returns the number of frozen tokens associated with the _userAddress.

Parameters

NameTypeDescription
_userAddressaddressThe address to check for frozen tokens.

Return Values

NameTypeDescription
[0]uint256The amount of frozen tokens for the specified address.

decimals

solidity
function decimals() external view returns (uint8)

Retrieves the number of decimals used for the token.

This function returns the decimal precision of the token.

Return Values

NameTypeDescription
[0]uint8The number of decimals used by the token.

name

solidity
function name() external view returns (string)

Retrieves the name of the token.

This function returns the name associated with the token.

Return Values

NameTypeDescription
[0]stringThe name of the token as a string.

onchainID

solidity
function onchainID() external view returns (address)

Retrieves the on-chain ID associated with the token.

This function returns the address representing the token's on-chain ID.

Return Values

NameTypeDescription
[0]addressThe address of on-chain ID of the token.

symbol

solidity
function symbol() external view returns (string)

Retrieves the symbol of the token.

This function returns the symbol that represents the token.

Return Values

NameTypeDescription
[0]stringThe symbol of the token as a string.

version

solidity
function version() external pure returns (string)

Retrieves the version of the token contract.

This function returns the version information of the token contract.

Return Values

NameTypeDescription
[0]stringThe version of the token contract as a string.

transfer

solidity
function transfer(address _to, uint256 _amount) public returns (bool)

ERC-20 overridden function that includes logic to check for trade validity.

_This function ensures that the sender and recipient addresses are not frozen, the sender has enough balance, and the recipient is a verified address.

Requirements:

  • The sender and the recipient addresses must not be frozen._

Parameters

NameTypeDescription
_toaddressThe address of the recipient.
_amountuint256The amount of tokens to transfer.

Return Values

NameTypeDescription
[0]booltrue if the transfer is successful; Reverted if unsuccessful. Errors: - TradeTokenWalletFrozen: Reverted if the sender or recipient is frozen. - TradeTokenInsufficientBalance: Reverted if the sender has insufficient available balance. - TransferNotPossible: Reverted if the recipient is not verified or the transfer is not allowed by compliance.

forcedTransfer

solidity
function forcedTransfer(address _from, address _to, uint256 _amount) public returns (bool)

Allows the agent to force a transfer of tokens from one address to another.

_This function checks if the sender has sufficient balance and ensures any frozen tokens are taken into account. If the transfer amount exceeds the free balance, it will unfreeze the necessary tokens. It also verifies that the recipient is a registered and verified address.

Requirements:

  • The caller must be an agent with the appropriate permissions._

Parameters

NameTypeDescription
_fromaddressThe address of the sender.
_toaddressThe address of the recipient.
_amountuint256The amount of tokens to transfer.

Return Values

NameTypeDescription
[0]booltrue if the transfer is successful; Reverted if unsuccessful. Errors: - TradeTokenInsufficientBalance: Reverted if the sender's balance is insufficient for the transfer. - TransferNotPossible: Reverted if the recipient is not verified or the transfer cannot be completed. Emits: - TokensUnfrozen: Emitted when tokens are unfrozen to facilitate the transfer.

mint

solidity
function mint(address _to, uint256 _amount) public

Mints new tokens and assign them to a specified address.

_This function mints the specified amount of tokens to the recipient's address.

Requirements:

  • The caller must be an agent with minting privileges._

Parameters

NameTypeDescription
_toaddressThe address of the recipient who will receive the minted tokens.
_amountuint256The number of tokens to mint. Errors: - TradeTokenMintingNotAllowed: Reverted if minting is not allowed if the token type is not Mintable. - TradeTokenIdentityNotVerified: Reverted if the recipient address is not verified in the identity registry. - TradeTokenComplianceViolation: Reverted if the token compliance rules prevent the minting and transfer.

burn

solidity
function burn(address _userAddress, uint256 _amount) public

Allows the agent to burn a specific amount of tokens from a user’s balance.

_This function burns a specific amount of tokens.

Requirements:

  • The caller must be an agent with burning previleges.
  • The user must have sufficient balance to burn, taking frozen tokens into account._

Parameters

NameTypeDescription
_userAddressaddressThe address of the user whose tokens will be burned.
_amountuint256The number of tokens to burn. Errors: - TradeTokenInsufficientBalance: Reverted if the user does not have enough balance to burn. Emits: - TokensUnfrozen: Emitted when tokens are unfrozen before burning.

setAddressFrozen

solidity
function setAddressFrozen(address _userAddress, bool _freeze) public

Allows the agent to freeze or unfreeze a user's address.

_This function sets the frozen state for a given address and emits an event indicating the change in the frozen status.

Requirements:

  • The caller must be an agent with necessary privileges._

Parameters

NameTypeDescription
_userAddressaddressThe address of the user whose frozen status will be changed.
_freezeboolA boolean indicating whether to freeze (true) or unfreeze (false) the user's address. Emits: - AddressFrozen: Emitted when a user’s address is frozen or unfrozen.

freezePartialTokens

solidity
function freezePartialTokens(address _userAddress, uint256 _amount) public

Allows the agent to freeze a partial amount of tokens for a user.

_This function freeze the requested amount and updates the frozen tokens accordingly.

Requirements:

  • The caller must be an agent with freezing privileges_

Parameters

NameTypeDescription
_userAddressaddressThe address of the user whose tokens will be frozen.
_amountuint256The number of tokens to freeze. Errors: - TradeTokenInsufficientBalance: Reverted if the user does not have enough tokens to freeze. Emits: - TokensFrozen: Emitted when tokens are successfully frozen.

unfreezePartialTokens

solidity
function unfreezePartialTokens(address _userAddress, uint256 _amount) public

Allows the agent to unfreeze a partial amount of tokens for a user.

_This function unfreez the frozen tokens and updates the frozen token balance.

Requirements:

  • The caller must be an agent with freezing/unfreezing privileges._

Parameters

NameTypeDescription
_userAddressaddressThe address of the user whose tokens will be unfrozen.
_amountuint256The number of tokens to unfreeze. Errors: - TradeTokenInsufficientBalance: Reverted if the user does not have enough frozen tokens to unfreeze. Emits: - TokensUnfrozen: Emitted when tokens are successfully unfrozen.

setIdentityRegistry

solidity
function setIdentityRegistry(address _identityRegistry) public

Allows the owner to set the identity registry address.

_This function updates the identity registry address.

Requirements:

  • The caller must be the owner of the contract._

Parameters

NameTypeDescription
_identityRegistryaddressThe address of the new identity registry. Emits: - IdentityRegistryAdded: Emitted when a new identity registry is set.

setCompliance

solidity
function setCompliance(address _compliance) public

Allows the owner to set the compliance contract address.

_This function updates the compliance contract address and binds the token to the new compliance system.

Requirements:

  • The caller must be the owner of the contract._

Parameters

NameTypeDescription
_complianceaddressThe address of the new compliance contract. Emits: - ComplianceAdded: Emitted when a new compliance system is added.

balanceOf

solidity
function balanceOf(address _userAddress) public view returns (uint256)

Returns the balance of tokens held by a user.

This function returns the token balance of the specified user.

Parameters

NameTypeDescription
_userAddressaddressThe address of the user whose balance is queried.

Return Values

NameTypeDescription
[0]uint256The balance of tokens held by the user.

_transfer

solidity
function _transfer(address _from, address _to, uint256 _amount) internal virtual

Transfer tokens between two addresses.

This function helps token transfer. It also triggers the _beforeTokenTransfer hook to perform any pre-transfer operations.

Parameters

NameTypeDescription
_fromaddressThe address to transfer tokens from.
_toaddressThe address to transfer tokens to.
_amountuint256The amount of tokens to transfer. Errors: - TradeTokenInvalidAddress: Reverted if either the sender or receiver address is the zero address. Emits: - Transfer: Emitted when tokens are transferred.

_mint

solidity
function _mint(address _userAddress, uint256 _amount) internal virtual

Mint new tokens and assign them to a user.

This function checks that the user address is valid, and mints new tokens to the user’s balance while updating the total supply.

Parameters

NameTypeDescription
_userAddressaddressThe address of the user to mint tokens for.
_amountuint256The amount of tokens to mint. Errors: - TradeTokenInvalidAddress: Reverted if the user address is the zero address. Emits: - Transfer: Emitted when tokens are minted and transferred to the user.

_burn

solidity
function _burn(address _userAddress, uint256 _amount) internal virtual

Allows to burn tokens from a user's balance.

_This function burns the token and reduces the user's balance and the total supply.

Errors:

  • TradeTokenInvalidAddress: Reverted if the user address is the zero address.

Emits:

  • Transfer: Emitted when tokens are burned and transferred from the user._

_approve

solidity
function _approve(address _owner, address _spender, uint256 _amount) internal virtual

Approve a spender to spend a specified amount of tokens.

This function helps to set spend limit for a spender set by owner.

Parameters

NameTypeDescription
_owneraddressThe address of the owner granting the allowance.
_spenderaddressThe address of the spender who is allowed to transfer tokens.
_amountuint256The amount of tokens the spender is allowed to transfer. Errors: - TradeTokenInvalidAddress: Reverted if either the owner or spender address is the zero address. Emits: - Approval: Emitted when the allowance is set.

_beforeTokenTransfer

solidity
function _beforeTokenTransfer(address _from, address _to, uint256 _amount) internal virtual

This is a hook that is called before any token transfer.

The function allows for custom logic to be implemented before the transfer occurs. It can be overridden in derived contracts to add additional behavior.

Parameters

NameTypeDescription
_fromaddressThe address from which the tokens are being transferred.
_toaddressThe address to which the tokens are being transferred.
_amountuint256The amount of tokens being transferred.

wrap

solidity
function wrap(uint256 _value, address _wrapperTradeToken, address _to) external

Wraps tokens into another TradeToken at a predefined ratio.

_This function allows a user to convert their tokens into another TradeToken, following a predefined wrap ratio.

Requirements:

  • The wrap ratio for the target TradeToken must be registered.
  • The caller must have sufficient balance to perform the wrap._

Parameters

NameTypeDescription
_valueuint256The amount of tokens to wrap.
_wrapperTradeTokenaddressThe address of the target TradeToken to wrap the tokens into.
_toaddressThe address to receive the wrapped tokens. Errors: - TradeTokenWalletFrozen: Reverted if the caller's or target TradeToken's wallet is frozen. - TradeTokenWrapRatioNotRegistered: Reverted if the wrap ratio for the target TradeToken is not registered. - TradeTokenInsufficientBalanceForWrap: Reverted if the caller does not have enough balance to wrap. - TransferNotPossible: Reverted if the transfer conditions are not met. Emits: - Transfer: Tokens transferred from the sender to the wrapper TradeToken.

unwrap

solidity
function unwrap(uint256 _value, address _wrappedTradeToken, address _to) external

Unwraps tokens back to their original form.

_This function allows the contract owner to reverse the wrapping process, converting wrapped tokens back into their original form.

Requirements:

  • The caller must be the contract owner.
  • The wrap ratio for the wrapped TradeToken must be registered._

Parameters

NameTypeDescription
_valueuint256The amount of wrapped tokens to unwrap.
_wrappedTradeTokenaddressThe address of the TradeToken containing the original tokens.
_toaddressThe address to receive the unwrapped tokens. Errors: - TradeTokenWalletFrozen: Reverted if either the caller's or wrapped TradeToken's wallet is frozen. - TradeTokenWrapRatioNotRegistered: Reverted if the wrap ratio for the wrapped TradeToken is not registered. - TradeTokenTransferFailed: Reverted if the transfer of unwrapped tokens fails. Emits: - Transfer: The wrapped tokens are burned from the caller's account and unwrapped original tokens are transferred to the recipient's address.

forcedUnwrap

solidity
function forcedUnwrap(address _from, uint256 _value, address _wrappedTradeToken, bytes _signature) external

Allows the contract owner to unwrap tokens of other holders back to their original form

Parameters

NameTypeDescription
_fromaddressAddress for which the wrapped tokens are being unwrapped
_valueuint256Amount of wrapped tokens to unwrap
_wrappedTradeTokenaddressAddress of the TradeToken containing the original tokens Requirements: - Caller must be the contract owner - Wrap ratio must be registered
_signaturebytes

onReceiveWrappedTokens

solidity
function onReceiveWrappedTokens(uint256 _value, address _to) external

Callback function for receiving wrapped tokens.

_This function is called when a TradeToken receives wrapped tokens. It verifies that the sender is a trusted contract and mints new tokens for the receiver.

Requirements:

  • The caller must be a verified twin contract._

Parameters

NameTypeDescription
_valueuint256The amount of tokens to mint for the receiver.
_toaddressThe address to receive the minted tokens. Emits: - Transfer: Emitted when new tokens are minted for the receiver.

setWrapRatio

solidity
function setWrapRatio(address _childTradeTokenAddress, uint256 _ratio) external

Sets the wrap ratio for a child TradeToken.

This function registers a wrap ratio for a child TradeToken.

Parameters

NameTypeDescription
_childTradeTokenAddressaddressThe address of the child TradeToken for which the wrap ratio is being set.
_ratiouint256The wrap ratio, scaled by 10^18. Errors: - TradeTokenUnauthorizedTradeTokenOwner: Reverted if the caller is not the owner of the child TradeToken. - TradeTokenWrapRatioAlreadyExists: Reverted if the wrap ratio is already set for the child TradeToken. Emits: - WrapRatioAdded: Emitted when the wrap ratio is successfully added for the child TradeToken.

getWrapRatio

solidity
function getWrapRatio(address _tradeTokenAddress) external view returns (uint256)

Returns the wrap ratio for a given TradeToken address.

This function queries and returns the wrap ratio associated with the specified TradeToken address.

Parameters

NameTypeDescription
_tradeTokenAddressaddressThe address of the TradeToken for which the wrap ratio is being queried.

Return Values

NameTypeDescription
[0]uint256The wrap ratio for the specified TradeToken address, scaled by 10^18.

onReceiveWrapRatio

solidity
function onReceiveWrapRatio(uint256 _ratio) external

Callback function when receiving a wrap ratio from another TradeToken.

_This function is called when a TradeToken receives a wrap ratio from another TradeToken.

Requirements:

  • Caller must be another TradeToken contract with the same deployed bytecode._

Parameters

NameTypeDescription
_ratiouint256The received wrap ratio, which represents the conversion factor between the TradeTokens. Emits: - WrapRatioReceived: Emitted when a wrap ratio is received, indicating the sender and the ratio.

addAttachment

solidity
function addAttachment(string _cid) external

Adds a new IPFS attachment to the contract.

_This function allows the contract owner to add a new IPFS attachment by registering its CID. The CID is stored along with the address of the submitter.

Requirements:

  • Caller must be the contract owner.
  • CID must not already be registered._

Parameters

NameTypeDescription
_cidstringIPFS Content Identifier for the attachment. Errors: - TradeTokenAttachmentAlreadyAdded: Reverted if the provided CID is already registered. Emits: - AttachmentAdded: Emitted when a new attachment is added, indicating the CID and the address of the submitter.

_verifyTwinContractBytecode

solidity
function _verifyTwinContractBytecode(address _target) internal view

Verifies that the target contract has identical bytecode to the current contract.

This function checks if the bytecode of the target contract matches the bytecode of the current contract.

Parameters

NameTypeDescription
_targetaddressAddress of the contract to verify Errors: - TradeTokenInvalidTwinContract: Reverted if the bytecode of the target contract does not match the current contract.