TokenFactory

Git Source

Author: Capsign Inc.

This contract is used to deploy new token contracts.

State Variables

implementations

mapping(bytes32 => TokenImplementation) public implementations;

allTokens

address[] public allTokens;

Functions

constructor

constructor(TokenImplementation[] memory _implementations);

addTokenImplementation

function addTokenImplementation(TokenImplementation memory _implementation) external;

createToken

createToken clones the implementation associated with the given tokenType, then initializes it for the owner.

function createToken(bytes32 tokenImplId, bytes calldata initCallData) external returns (address token);

Parameters

Name
Type
Description

tokenImplId

bytes32

The identifier of the token implementation.

initCallData

bytes

The call data to initialize the token contract.

Returns

Name
Type
Description

token

address

The address of the newly deployed token contract.

getAllTokens

Returns the full list of deployed asset addresses.

function getAllTokens() external view returns (address[] memory);

_getRevertMsg

Returns the revert message from a transaction.

function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory);

Parameters

Name
Type
Description

_returnData

bytes

The return data from the transaction.

Returns

Name
Type
Description

<none>

string

The revert message.

Events

TokenFactoryCreated

Emitted when a new token factory is created.

event TokenFactoryCreated(address indexed tokenFactoryAddress);

Parameters

Name
Type
Description

tokenFactoryAddress

address

The address of the newly deployed token factory contract.

TokenCreated

Emitted when a new token is created.

event TokenCreated(address indexed tokenAddress, address indexed creator, bytes32 indexed tokenImplId);

Parameters

Name
Type
Description

tokenAddress

address

The address of the newly deployed token contract.

creator

address

The creator of the token contract.

tokenImplId

bytes32

The identifier of the token implementation.

TokenImplementationAdded

Emitted when a new implementation is added.

event TokenImplementationAdded(
    bytes32 indexed implementationId, string tokenType, address implementation, bytes4 requiredSelector, bool issued
);

Parameters

Name
Type
Description

implementationId

bytes32

The identifier of the implementation.

tokenType

string

The type of the token contract.

implementation

address

The address of the implementation.

requiredSelector

bytes4

The required selector for the implementation.

issued

bool

Whether the token is issued.

Structs

TokenImplementation

struct TokenImplementation {
    string tokenType;
    address implementation;
    bytes4 requiredSelector;
    bool issued;
}

Last updated

Was this helpful?