StructSPToken
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
Name | Type | Description |
---|---|---|
from | address | The address to transfer tokens from |
to | address | The address to transfer tokens to |
id | uint256 | The ID of the token to transfer |
amount | uint256 | The amount of the token to transfer |
data | bytes | Additional 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
Name | Type | Description |
---|---|---|
from | address | The address to transfer tokens from |
to | address | The address to transfer tokens to |
ids | uint256[] | The IDs of the tokens to transfer |
amounts | uint256[] | The amounts of the tokens to transfer |
data | bytes | Additional 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
Name | Type | Description |
---|---|---|
to | address | The address to assign the minted tokens to |
id | uint256 | The ID of the token to mint |
amount | uint256 | The amount of the token to mint |
data | bytes | Additional 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
Name | Type | Description |
---|---|---|
to | address | The address to assign the minted tokens to |
ids | uint256[] | The IDs of the tokens to mint |
amounts | uint256[] | The amounts of the tokens to mint |
data | bytes | Additional 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
Name | Type | Description |
---|---|---|
from | address | The address of the token owner. |
id | uint256 | The ID of the token to burn. |
amount | uint256 | The 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
Name | Type | Description |
---|---|---|
from | address | The address of the token owner. |
ids | uint256[] | The IDs of the tokens to burn. |
amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
operator | address | The address performing the operation. |
from | address | The address from which the tokens are transferred. |
to | address | The address to which the tokens are transferred. |
ids | uint256[] | The IDs of the tokens being transferred. |
amounts | uint256[] | The amounts of tokens being transferred. |
data | bytes | Additional 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
Name | Type | Description |
---|---|---|
newuri | string | The new URI to set. |
setFeyProductFactory
Set the address of the FeyProductFactory contract.
function setFeyProductFactory(IFEYFactory _feyProductFactory) external onlyRole(GOVERNANCE);
Parameters
Name | Type | Description |
---|---|---|
_feyProductFactory | IFEYFactory | The 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
Name | Type | Description |
---|---|---|
newuri | string | The 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
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | The ID of the interface to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | A boolean indicating whether the contract implements the interface with the given ID. |