Skip to main content

StructSPToken

Git Source

Inherits: StructERC1155, GACManaged

Author: Struct Finance

A simple implementation of ERC1155 token using OpenZeppelin libraries

This contract implements the StructSP Token, which is an ERC1155 token using OpenZeppelin libraries. It also makes use of GACManaged for access control.

State Variables

_uri

string private _uri;

feyProductFactory

IFEYFactory private feyProductFactory;

Functions

constructor

constructor(IGAC _globalAccessControl, IFEYFactory _feyProductFactory);

safeTransferFrom

Transfers tokens from one address to another

function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data)
public
virtual
override
gacPausable;

Parameters

NameTypeDescription
fromaddressThe address to transfer tokens from
toaddressThe address to transfer tokens to
iduint256The ID of the token to transfer
amountuint256The amount of the token to transfer
databytesAdditional data with no specified format

safeBatchTransferFrom

Transfers multiple types of tokens from one address to another

function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) public virtual override gacPausable;

Parameters

NameTypeDescription
fromaddressThe address to transfer tokens from
toaddressThe address to transfer tokens to
idsuint256[]The IDs of the tokens to transfer
amountsuint256[]The amounts of the tokens to transfer
databytesAdditional data with no specified format

mint

Mints tokens and assigns them to an address

function mint(address to, uint256 id, uint256 amount, bytes memory data) public virtual gacPausable onlyRole(PRODUCT);

Parameters

NameTypeDescription
toaddressThe address to assign the minted tokens to
iduint256The ID of the token to mint
amountuint256The amount of the token to mint
databytesAdditional data with no specified format

mintBatch

Mints multiple types of tokens and assigns them to an address

function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
public
virtual
gacPausable
onlyRole(PRODUCT);

Parameters

NameTypeDescription
toaddressThe address to assign the minted tokens to
idsuint256[]The IDs of the tokens to mint
amountsuint256[]The amounts of the tokens to mint
databytesAdditional data with no specified format

burn

Burn a certain amount of a specific token ID.

function burn(address from, uint256 id, uint256 amount) public virtual onlyRole(PRODUCT) gacPausable;

Parameters

NameTypeDescription
fromaddressThe address of the token owner.
iduint256The ID of the token to burn.
amountuint256The amount of tokens to burn.

burnBatch

Burn multiple amounts of different token IDs.

function burnBatch(address from, uint256[] memory ids, uint256[] memory amounts)
public
virtual
onlyRole(PRODUCT)
gacPausable;

Parameters

NameTypeDescription
fromaddressThe address of the token owner.
idsuint256[]The IDs of the tokens to burn.
amountsuint256[]The amounts of tokens to burn.

_beforeTokenTransfer

Hook that restricts the token transfers if the state of the associated product is not INVESTED.

Also restricts the minting once the deposits are closed for the associated product.

function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override gacPausable;

Parameters

NameTypeDescription
operatoraddressThe address performing the operation.
fromaddressThe address from which the tokens are transferred.
toaddressThe address to which the tokens are transferred.
idsuint256[]The IDs of the tokens being transferred.
amountsuint256[]The amounts of tokens being transferred.
databytesAdditional data with no specified format.

setURI

if mint, check if minting is enabled for the product for transfers (excluding burn()), check if transfer is enabled for the product

Set the base token URI for all token IDs.

function setURI(string memory newuri) external onlyRole(GOVERNANCE);

Parameters

NameTypeDescription
newuristringThe new URI to set.

setFeyProductFactory

Set the address of the FeyProductFactory contract.

function setFeyProductFactory(IFEYFactory _feyProductFactory) external onlyRole(GOVERNANCE);

Parameters

NameTypeDescription
_feyProductFactoryIFEYFactoryThe address of the FeyProductFactory contract.

_setURI

Internal function to set the base token URI for all token IDs.

function _setURI(string memory newuri) internal virtual;

Parameters

NameTypeDescription
newuristringThe new URI to set.

uri

Returns the base token URI for all token IDs.

function uri(uint256) public view virtual override returns (string memory);

supportsInterface

Override function required by ERC-165 to check if a contract implements a given interface.

function supportsInterface(bytes4 interfaceId) public pure override(StructERC1155) returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4The ID of the interface to check.

Returns

NameTypeDescription
<none>boolA boolean indicating whether the contract implements the interface with the given ID.