Appearance
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
Name | Type | Description |
---|---|---|
cid | string | The IPFS Content Identifier of the attachment |
submitter | address | The 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
Name | Type | Description |
---|---|---|
childTradeTokenAddress | address | The address of the child Trade Token |
ratio | uint256 | The 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
Name | Type | Description |
---|---|---|
tradeTokenAddress | address | The address of the Trade Token setting the ratio |
ratio | uint256 | The 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
Name | Type | Description |
---|---|---|
target | address | Address 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
Name | Type | Description |
---|---|---|
target | address | Address 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
Name | Type | Description |
---|---|---|
target | address | Address 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
Name | Type | Description |
---|---|---|
target | address | Address 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
Name | Type | Description |
---|---|---|
available | uint256 | The amount of tokens available in the user's balance. |
required | uint256 | The 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
Name | Type | Description |
---|---|---|
to | address | Address to which the transfer was intended. |
value | uint256 | The 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
Name | Type | Description |
---|---|---|
cid | string | The 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
Name | Type | Description |
---|---|---|
invalidAddress | address | The 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
Name | Type | Description |
---|---|---|
invalidArgument | string | The 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
Name | Type | Description |
---|---|---|
invalidDecimals | uint8 | The 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
Name | Type | Description |
---|---|---|
walletAddress | address | The 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
Name | Type | Description |
---|---|---|
walletAddress | address | The 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
Name | Type | Description |
---|---|---|
available | uint256 | The amount of tokens available in the user's balance. |
required | uint256 | The 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
Name | Type | Description |
---|---|---|
account | address | The 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
Name | Type | Description |
---|---|---|
from | address | Address of the sender involved in the violation. |
to | address | Address of the recipient involved in the violation. |
amount | uint256 | The 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 (eitherMintable
orWrappable
)._
Parameters
Name | Type | Description |
---|---|---|
_tradeTokenType | enum TradeToken3643.TradeTokenType | The 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 beaddress(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
Name | Type | Description |
---|---|---|
_identityRegistry | address | The address of the Identity registry linked to the token. |
_compliance | address | The address of the compliance contract linked to the token. |
_name | string | The name of the token. |
_symbol | string | The symbol of the token. |
_decimals | uint8 | The number of decimals for the token. |
_onchainID | address | The 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
Name | Type | Description |
---|---|---|
_spender | address | The address of the spender who will be approved. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_spender | address | The address of the spender whose allowance will be increased. |
_addedValue | uint256 | The 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
Name | Type | Description |
---|---|---|
_spender | address | The address of the spender whose allowance will be decreased. |
_subtractedValue | uint256 | The 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
Name | Type | Description |
---|---|---|
_name | string | The 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
Name | Type | Description |
---|---|---|
_symbol | string | The 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
Name | Type | Description |
---|---|---|
_onchainID | address | The 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
Name | Type | Description |
---|---|---|
_toList | address[] | List of recipient addresses. |
_amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
_from | address | The address of the sender. |
_to | address | The address of the receiver. |
_amount | uint256 | The number of tokens to transfer. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | true 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
Name | Type | Description |
---|---|---|
_fromList | address[] | The list of addresses to transfer tokens from. |
_toList | address[] | The list of addresses to transfer tokens to. |
_amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
_toList | address[] | The list of addresses to mint tokens to. |
_amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
_userAddresses | address[] | The list of addresses whose tokens will be burned. |
_amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
_userAddresses | address[] | The list of addresses to freeze or unfreeze. |
_freeze | bool[] | 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
Name | Type | Description |
---|---|---|
_userAddresses | address[] | The list of addresses whose tokens will be partially frozen. |
_amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
_userAddresses | address[] | The list of addresses whose tokens will be partially unfrozen. |
_amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
_lostWallet | address | The address of the wallet whose tokens and settings are to be recovered. |
_newWallet | address | The address of the wallet that will receive the tokens and settings. |
_investorOnchainID | address | The 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
Name | Type | Description |
---|---|---|
[0] | uint256 | The 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
Name | Type | Description |
---|---|---|
_owner | address | The address of the token owner. |
_spender | address | The address of the spender. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The 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
Name | Type | Description |
---|---|---|
[0] | contract IIdentityRegistry | The 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
Name | Type | Description |
---|---|---|
[0] | contract IModularCompliance | The 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
Name | Type | Description |
---|---|---|
[0] | bool | true 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
Name | Type | Description |
---|---|---|
_userAddress | address | The address to check for the frozen status. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | true 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
Name | Type | Description |
---|---|---|
_userAddress | address | The address to check for frozen tokens. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The 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
Name | Type | Description |
---|---|---|
[0] | uint8 | The 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
Name | Type | Description |
---|---|---|
[0] | string | The 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
Name | Type | Description |
---|---|---|
[0] | address | The 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
Name | Type | Description |
---|---|---|
[0] | string | The 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
Name | Type | Description |
---|---|---|
[0] | string | The 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
Name | Type | Description |
---|---|---|
_to | address | The address of the recipient. |
_amount | uint256 | The amount of tokens to transfer. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | true 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
Name | Type | Description |
---|---|---|
_from | address | The address of the sender. |
_to | address | The address of the recipient. |
_amount | uint256 | The amount of tokens to transfer. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | true 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
Name | Type | Description |
---|---|---|
_to | address | The address of the recipient who will receive the minted tokens. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_userAddress | address | The address of the user whose tokens will be burned. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_userAddress | address | The address of the user whose frozen status will be changed. |
_freeze | bool | A 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
Name | Type | Description |
---|---|---|
_userAddress | address | The address of the user whose tokens will be frozen. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_userAddress | address | The address of the user whose tokens will be unfrozen. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_identityRegistry | address | The 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
Name | Type | Description |
---|---|---|
_compliance | address | The 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
Name | Type | Description |
---|---|---|
_userAddress | address | The address of the user whose balance is queried. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The 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
Name | Type | Description |
---|---|---|
_from | address | The address to transfer tokens from. |
_to | address | The address to transfer tokens to. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_userAddress | address | The address of the user to mint tokens for. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_owner | address | The address of the owner granting the allowance. |
_spender | address | The address of the spender who is allowed to transfer tokens. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_from | address | The address from which the tokens are being transferred. |
_to | address | The address to which the tokens are being transferred. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_value | uint256 | The amount of tokens to wrap. |
_wrapperTradeToken | address | The address of the target TradeToken to wrap the tokens into. |
_to | address | The 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
Name | Type | Description |
---|---|---|
_value | uint256 | The amount of wrapped tokens to unwrap. |
_wrappedTradeToken | address | The address of the TradeToken containing the original tokens. |
_to | address | The 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
Name | Type | Description |
---|---|---|
_from | address | Address for which the wrapped tokens are being unwrapped |
_value | uint256 | Amount of wrapped tokens to unwrap |
_wrappedTradeToken | address | Address of the TradeToken containing the original tokens Requirements: - Caller must be the contract owner - Wrap ratio must be registered |
_signature | bytes |
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
Name | Type | Description |
---|---|---|
_value | uint256 | The amount of tokens to mint for the receiver. |
_to | address | The 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
Name | Type | Description |
---|---|---|
_childTradeTokenAddress | address | The address of the child TradeToken for which the wrap ratio is being set. |
_ratio | uint256 | The 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
Name | Type | Description |
---|---|---|
_tradeTokenAddress | address | The address of the TradeToken for which the wrap ratio is being queried. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The 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
Name | Type | Description |
---|---|---|
_ratio | uint256 | The 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
Name | Type | Description |
---|---|---|
_cid | string | IPFS 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
Name | Type | Description |
---|---|---|
_target | address | Address of the contract to verify Errors: - TradeTokenInvalidTwinContract : Reverted if the bytecode of the target contract does not match the current contract. |