Skip to content

Solidity API

TradeTokenFactory

_Factory contract for deploying TradeToken contract using CREATE2.

This implementation provides a way to deterministically deploy TradeToken contract using the CREATE2 opcode.

The factory can deploy different types of TradeToken contract based on the TradeTokenType enum defined in the TradeToken contract._

TradeTokenCreated

solidity
event TradeTokenCreated(address _address, bytes32 _salt)

Emitted when a new TradeToken contract is created.

Parameters

NameTypeDescription
_addressaddressThe address of the newly deployed TradeToken contract
_saltbytes32The salt value used in CREATE2 deployment

TradeTokenCreate2Failed

solidity
error TradeTokenCreate2Failed()

Error thrown when the CREATE2 deployment fails

deployTradeTokenFromFactory

solidity
function deployTradeTokenFromFactory(string _tokenName, string _tokenSymbol, uint256 _initialSupply, bytes32 _salt, enum TradeToken.TradeTokenType _tradeTokenType) public returns (address)

_Deploys a new TradeToken contract using CREATE2.

This function creates a new TradeToken contract with the specified parameters. The address of the deployed contract is deterministic and depends on the salt value.

Requirements:

  • The deployment must not fail
  • The salt value must not have been used before_

Parameters

NameTypeDescription
_tokenNamestringThe name of the token
_tokenSymbolstringThe symbol of the token
_initialSupplyuint256The initial supply of tokens to mint
_saltbytes32A unique value used to determine the contract address
_tradeTokenTypeenum TradeToken.TradeTokenTypeThe type of TradeToken to deploy

Return Values

NameTypeDescription
[0]addressdeployedAddress The address of the newly deployed TradeToken contract