πA sample about token vesting
In this Smart Scenario; It is divided into equal periods of 10 months (Per month 2.1 Million PIRI). The asset is coded so that it can only be claimed once a month.
const InvestorAddress='PRTMRKWZ56v4D8mV1oj813bqTgdfUm9J4woVTDMpGxF';
const totalAmount=43_333; // for only testing.
const cliffDate={};
cliffDate["_2024"]=totalAmount*0.05; // Pay %5 on 2024
cliffDate["_2025"]=totalAmount*0.2; // Pay %25 on 2025
cliffDate["_2026"]=totalAmount*0.75; // Pay %75 in 2026
async function withdraw(amount)
{
if (EXECUTER_ADDRESS!==InvestorAddress)
{
return {error:1,data:'This PSce doesnt belong to you!'};
}
if (isNaN(amount))
return {error:1,data:'Amount is not true format!'};
if (parseFloat(amount)<=0)
return {error:1,data:'Amount must be positive number!'};
if (parseFloat(amount)>totalAmount)
return {error:1,data:'Amount must be lower than total amount'};
if (PSDATA==undefined) PSDATA={};
if (PSDATA["withDraw"+new Date().getFullYear().toString()]==undefined)
PSDATA["withDraw"+new Date().getFullYear().toString()]=0;
if (PSDATA["withDraw"+new Date().getFullYear().toString()]+amount<=cliffDate["_"+new Date().getFullYear()])
{
PSDATA["takenDate_"+new Date().toString()]=amount;
PSDATA["withDraw"+new Date().getFullYear().toString()]+=amount;
await Map.saveMap(JSON.stringify(PSDATA));
return await Transaction.sendPIRI(InvestorAddress,amount);
}
else
{
return {error:1,data:'You wont take this amount because of exceed to cliff limit!' };
}
}Last updated