Voucher
Function definitions, parameter descriptions, and use cases of the APIs of IcToken smart contract.
function mint(uint64 term, uint256 amount, uint64[] calldata maturities, uint32[] calldata percentages, string memory originalInvestor) external returns (uint256, uint256);
Parameter | Type | Note |
term | uint64 | Release term:
One-time release type: fixed at 0;
Linear and Staged release type: duration in seconds from start to end of release |
amount | uint256 | Amount of assets (ERC20) to be locked up |
maturities | uint64[] | Timestamp of each release time node |
percentages | uint32[] | Release percentage of each release time node |
originalInvestor | string | Note indicating the original invester |
- Lengths of maturities and percentages must be equal;
- The precision of the release percentage is 0.01% (i.e., a value of 10000 means 100%). Thus, the sum of all elements of percentages must be equal to 10000;
- For Staged release type, the value of term must be equal to the time difference between the first and the last release time node;
- The corresponding ERC20 token should be approved to the IcToken contract before mint.
Parameter | Type | Note |
slot | uint256 | Slot of the minted Voucher |
tokenId | uint256 | Id of the minted Voucher |
- Linear Release Typeuint64 term = 86400 * 30;uint256 amount = 1000000000000000000;uint64[] memory maturities;maturities[0] = uint64(block.timestamp + 86400 * 60);uint32[] memory percentages;percentages[0] = 10000;string memory originalInvestor = "investor";icToken.mint(term, amount, maturities, percentages, originalInvestor);
- One-time Release Typeuint64 term = 0;uint256 amount = 1000000000000000000;uint64[] memory maturities;maturities[0] = uint64(block.timestamp + 86400 * 30);uint32[] memory percentages;percentages[0] = 10000;string memory originalInvestor = "investor";icToken.mint(term, amount, maturities, percentages, originalInvestor);
- Staged Release Typeuint64 term = 86400 * 60;uint256 amount = 1000000000000000000;uint64[] memory maturities;maturities[0] = uint64(block.timestamp + 86400 * 30);maturities[1] = uint64(block.timestamp + 86400 * 60);maturities[2] = uint64(block.timestamp + 86400 * 90);uint32[] memory percentages;percentages[0] = 3000;percentages[1] = 3000;percentages[2] = 4000;string memory originalInvestor = "investor";icToken.mint(term, amount, maturities, percentages, originalInvestor);
- Linear Release Typelet now = (await wallet.provider.getBlock()).timestamp;let term = 86400 * 30;let amount = 1000000000000000000n;let maturities = [now + 86400 * 60];let percentages = [10000];let originalInvestor = "investor";await icToken.mint(term, amount, maturities, percentages, originalInvestor);
- One-time Release Typelet now = (await wallet.provider.getBlock()).timestamp;let term = 0;let amount = 1000000000000000000n;let maturities = [now + 86400 * 30];let percentages = [10000];let originalInvestor = "investor";await icToken.mint(term, amount, maturities, percentages, originalInvestor);
- Staged Release Typelet now = (await wallet.provider.getBlock()).timestamp;let term = 86400 * 60;let amount = 1000000000000000000n;let maturities = [now + 86400 * 30, now + 86400 * 60, now + 86400 * 90];let percentages = [3000, 3000, 4000];let originalInvestor = "investor";await icToken.mint(term, amount, maturities, percentages, originalInvestor);
Claim specified amount of assets of target Voucher.
function claim(uint256 tokenId, uint256 amount) external;
Parameter | Type | Note |
tokenId | uint256 | Id of the Voucher to claim |
amount | uint256 | Amount of assets (ERC20) to claim |
uint256 tokenId = 101;
uint256 claimAmount = 500000000000000000;
icToken.claim(tokenId, claimAmount);
let tokenId = 101;
let amount = 500000000000000000n;
await icToken.claim(tokenId, amount);
Claim All underlying assets of target Voucher.
function claimAll(uint256 tokenId) external;
Parameter | Type | Note |
tokenId | uint256 | Id of the Voucher to claim |
uint256 tokenId = 101;
icToken.claimAll(tokenId);
let tokenId = 101;
await icToken.claimAll(tokenId);
Query the released amount of the underlying assets.
function claimableAmount(uint256 tokenId) external view returns(uint256);
Parameter | Type | Note |
tokenId | uint256 | Id of the Voucher to query |
Parameter | Type | Note |
claimableAmount | uint256 | Released amount of the underlying assets |
uint256 tokenId = 101;
uint256 amount = icToken.claimableAmount(tokenId);
let tokenId = 101;
let amount = await icToken.claimableAmount(tokenId);
function transferFrom(address from, address to, uint256 tokenId) public;
Parameter | Type | Note |
from | address | Address of the Voucher sender |
to | address | Address of the Voucher recipient |
tokenId | uint256 | Id of the Voucher to transfer |
address from = 0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F;
address to = 0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF;
uint256 tokenId = 101;
icToken.transferFrom(from, to, tokenId);
let from = "0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF";
let to = "0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F";
let tokenId = 101;
await icToken.transferFrom(from, to, tokenId);
function transferFrom(address from, address to, uint256 tokenId, uint256 transferUnits) public returns (uint256 newTokenId);
Parameter | Type | Note |
from | address | Address of the Voucher sender |
to | address | Address of the Voucher recipient |
tokenId | uint256 | Id of the Voucher to transfer |
transferUnits | uint256 | Amount of units to transfer |
Parameter | Type | Note |
newTokenId | uint256 | Id of the Voucher created after transfer |
address from = 0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F;
address to = 0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF;
uint256 tokenId = 101;
uint256 units = 100000000000000000;
icToken.transferFrom(from, to, tokenId, units);
let from = "0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF";
let to = "0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F";
let tokenId = 101;
let units = 100000000000000000n;
await icToken.transferFrom(from, to, tokenId, units);
function setApprovalForAll(address operator, bool approved) public;
Parameter | Type | Note |
operator | address | Address to be authorized |
approved | bool | Whether to approve all Vouchers to operator |
address operator = 0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF;
icToken.setApprovalForAll(operator, true);
let operator = "0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F";
let approved = true;
await icToken.setApprovalForAll(operator, approved);
Last modified 1yr ago