Voucher
Function definitions, parameter descriptions, and use cases of the APIs of IcToken smart contract.

mint

Function Definition

1
function mint(uint64 term, uint256 amount, uint64[] calldata maturities, uint32[] calldata percentages, string memory originalInvestor) external returns (uint256, uint256);
Copied!

Input Parameters

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

Note:

    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.

Output Parameters

Parameter
Type
Note
slot
uint256
Slot of the minted Voucher
tokenId
uint256
Id of the minted Voucher

Use Cases

Use Cases in Solidity

    Linear Release Type
    1
    uint64 term = 86400 * 30;
    2
    uint256 amount = 1000000000000000000;
    3
    uint64[] memory maturities;
    4
    maturities[0] = uint64(block.timestamp + 86400 * 60);
    5
    uint32[] memory percentages;
    6
    percentages[0] = 10000;
    7
    string memory originalInvestor = "investor";
    8
    icToken.mint(term, amount, maturities, percentages, originalInvestor);
    Copied!
    One-time Release Type
    1
    uint64 term = 0;
    2
    uint256 amount = 1000000000000000000;
    3
    uint64[] memory maturities;
    4
    maturities[0] = uint64(block.timestamp + 86400 * 30);
    5
    uint32[] memory percentages;
    6
    percentages[0] = 10000;
    7
    string memory originalInvestor = "investor";
    8
    icToken.mint(term, amount, maturities, percentages, originalInvestor);
    Copied!
    Staged Release Type
    1
    uint64 term = 86400 * 60;
    2
    uint256 amount = 1000000000000000000;
    3
    uint64[] memory maturities;
    4
    maturities[0] = uint64(block.timestamp + 86400 * 30);
    5
    maturities[1] = uint64(block.timestamp + 86400 * 60);
    6
    maturities[2] = uint64(block.timestamp + 86400 * 90);
    7
    uint32[] memory percentages;
    8
    percentages[0] = 3000;
    9
    percentages[1] = 3000;
    10
    percentages[2] = 4000;
    11
    string memory originalInvestor = "investor";
    12
    icToken.mint(term, amount, maturities, percentages, originalInvestor);
    Copied!

Use Cases with ethers.js

    Linear Release Type
    1
    let now = (await wallet.provider.getBlock()).timestamp;
    2
    let term = 86400 * 30;
    3
    let amount = 1000000000000000000n;
    4
    let maturities = [now + 86400 * 60];
    5
    let percentages = [10000];
    6
    let originalInvestor = "investor";
    7
    await icToken.mint(term, amount, maturities, percentages, originalInvestor);
    Copied!
    One-time Release Type
    1
    let now = (await wallet.provider.getBlock()).timestamp;
    2
    let term = 0;
    3
    let amount = 1000000000000000000n;
    4
    let maturities = [now + 86400 * 30];
    5
    let percentages = [10000];
    6
    let originalInvestor = "investor";
    7
    await icToken.mint(term, amount, maturities, percentages, originalInvestor);
    Copied!
    Staged Release Type
    1
    let now = (await wallet.provider.getBlock()).timestamp;
    2
    let term = 86400 * 60;
    3
    let amount = 1000000000000000000n;
    4
    let maturities = [now + 86400 * 30, now + 86400 * 60, now + 86400 * 90];
    5
    let percentages = [3000, 3000, 4000];
    6
    let originalInvestor = "investor";
    7
    await icToken.mint(term, amount, maturities, percentages, originalInvestor);
    Copied!

claim

Function Definition

Claim specified amount of assets of target Voucher.
1
function claim(uint256 tokenId, uint256 amount) external;
Copied!

Input Parameters

Parameter
Type
Note
tokenId
uint256
Id of the Voucher to claim
amount
uint256
Amount of assets (ERC20) to claim

Use Cases

Use Cases in Solidity

1
uint256 tokenId = 101;
2
uint256 claimAmount = 500000000000000000;
3
icToken.claim(tokenId, claimAmount);
Copied!

Use Cases with ethers.js

1
let tokenId = 101;
2
let amount = 500000000000000000n;
3
await icToken.claim(tokenId, amount);
Copied!

claimAll

Claim All underlying assets of target Voucher.

Function Definition

1
function claimAll(uint256 tokenId) external;
Copied!

Input Parameters

Parameter
Type
Note
tokenId
uint256
Id of the Voucher to claim

Use Cases

Use Cases in Solidity

1
uint256 tokenId = 101;
2
icToken.claimAll(tokenId);
Copied!

Use Cases with ethers.js

1
let tokenId = 101;
2
await icToken.claimAll(tokenId);
Copied!

claimableAmount

Function Definition

Query the released amount of the underlying assets.
1
function claimableAmount(uint256 tokenId) external view returns(uint256);
Copied!

Input Parameters

Parameter
Type
Note
tokenId
uint256
Id of the Voucher to query

Output Parameters

Parameter
Type
Note
claimableAmount
uint256
Released amount of the underlying assets

Use Cases

Use Cases in Solidity

1
uint256 tokenId = 101;
2
uint256 amount = icToken.claimableAmount(tokenId);
Copied!

Use Cases with ethers.js

1
let tokenId = 101;
2
let amount = await icToken.claimableAmount(tokenId);
Copied!

transferFrom (transfer all)

Function Definition

1
function transferFrom(address from, address to, uint256 tokenId) public;
Copied!

Input Parameters

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

Use Cases

Use Cases in Solidity

1
address from = 0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F;
2
address to = 0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF;
3
uint256 tokenId = 101;
4
icToken.transferFrom(from, to, tokenId);
Copied!

Use Cases with ethers.js

1
let from = "0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF";
2
let to = "0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F";
3
let tokenId = 101;
4
await icToken.transferFrom(from, to, tokenId);
Copied!

transferFrom (partial transfer)

Function Definition

1
function transferFrom(address from, address to, uint256 tokenId, uint256 transferUnits) public returns (uint256 newTokenId);
Copied!

Input Parameters

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

Output Parameters

Parameter
Type
Note
newTokenId
uint256
Id of the Voucher created after transfer

Use Cases

Use Cases in Solidity

1
address from = 0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F;
2
address to = 0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF;
3
uint256 tokenId = 101;
4
uint256 units = 100000000000000000;
5
icToken.transferFrom(from, to, tokenId, units);
Copied!

Use Cases with ethers.js

1
let from = "0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF";
2
let to = "0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F";
3
let tokenId = 101;
4
let units = 100000000000000000n;
5
await icToken.transferFrom(from, to, tokenId, units);
Copied!

setApprovalForAll

Function Definition

1
function setApprovalForAll(address operator, bool approved) public;
Copied!

Input Parameters

Parameter
Type
Note
operator
address
Address to be authorized
approved
bool
Whether to approve all Vouchers to operator

Use Cases

Use Cases in Solidity

1
address operator = 0xabcdE6D60F48cBE31202C766BbB0EE16AD0b47FF;
2
icToken.setApprovalForAll(operator, true);
Copied!

Use Cases with ethers.js

1
let operator = "0x9a837E6d6fA9aA9Ee1DbBb7e260c38c7943A015F";
2
let approved = true;
3
await icToken.setApprovalForAll(operator, approved);
Copied!
Last modified 4mo ago