ICO Launchpad Smart contract for solana spl tokens and spl token 2022
Need to build up anchor development environment
anchor version 0.30.1
solana version 1.18.18
node version 23.3.0
- Prepare anchor development environments.
- Prepare around 7 SOL in the deploy wallet keypair. (3 SOL for deploy cost and should hold around 4 SOL for redeployment)
- Confirm Network cluster in
Anchor.tomlfile : f.e.[programs.devnet],cluster = "devnet" - Confirm deploy authority wallet keypair location : f.e. `wallet = "../deploy.json"
- Configure solana cli with deploy authority keypair and deploying cluster : f.e.
solana config set -h - Build program with
anchor build. - Copy and paste the result deploy scripts from Build terminal message: f.e.
solana program deploy /home/ubuntu/project/target/deploy/nut_marketplace.so - Or can use
anchor deployif configuredAnchor.tomlcorrectly.
- Delete the program keypair in
/target/deploy/nut_marketplace-keypair.json - Build project with
anchor build. This will generate new keypair - Get the address of new keypair with
solana address --keypair ./target/deploy/nut_marketplace-keypair.json - Change program addresses in project code.
Anchor.toml,/program/nut_marketplace/src/lib.rs - Build program object again with
anchor build - Deploy newly built so file with
solana program deploy
Or can useanchor keys sync/anchor build/anchor deploywith anchor-cli.
Able to run all commands in /cli/command.ts file by running yarn ts-node xxx.
When you get this error
Error: Provider local is not available on browser.
You can run this command export BROWSER= once.
- Install
nodeandyarn - Install
ts-nodeas global command
- Initialize program with
initcommand
Initialize Program with creating Global PDA account as Contract Deployer.
Get global PDA info of program. This will show the launchpad admin authority and state represent whether the whole launchpad is paused or not.
Admin able to pause or resume launchpad with this command as Admin.
pausedtrue or false
Admin able to transfer admin authority to another.
new_adminis the new authority address
Create ICO Pot and become its owner.
ico_mintis the ICO token mintico_is_token22is option should be true if the ICO token is spl token 2022cost_mintis the cost token mintcost_is_token22is option should be true if the cost token is spl token 2022amountis the amount to selling ICO tokensstart_priceis price of 1 ICO token in cost tokens. Has same decimal with ICO tokenend_priceif 0 then price is fixed, else price grows liner from startPrice to endPrice based on sold tokensstart_datetimestamp when ICO starts. The date must be in futureend_datetimestamp when ICO ends, if 0 then ICO will be active until sell all tokensbonus_reserveamount of tokens that will be used for bonusbonus_percentagepercent of bonus (with 2 decimals) which will be added to bought amountbonus_activatorpercent of total ICO tokens that should be bought to activate bonus (with 2 decimals)unlock_percentagepercentage (with 2 decimals) of initially unlocked tokencliff_periodcliff period (in seconds)vesting_percentagepercentage (with 2 decimals) of locked tokens will be unlocked every intervalvesting_intervalinterval (in seconds) of vesting
ICO Pot owner able to close and refund remained ICO tokens.
icois the PDA address of ICO Potico_is_token22is option should be true if the ICO token is spl token 2022
Buyers can purchase the ICO token by paying with cost tokens.
icois the PDA address of ICO Potamountis the quantity of buyingico_is_token22is option should be true if the ICO token is spl token 2022cost_is_token22is option should be true if the cost token is spl token 2022
Buyers can claim unlocked ICO tokens if has vesting from their purchase.
icois the PDA address of ICO Potico_is_token22is option should be true if the ICO token is spl token 2022
ICO owner able to withdraw collected cost tokens.
icois the PDA address of ICO Potcost_is_token22is option should be true if the cost token is spl token 2022
Admin able to force withdraw any tokens from a certain ICO Pot.
icois the PDA address of ICO Potico_is_token22is option should be true if the ICO token is spl token 2022
Get ICO PDA info. This will show the ICO states and configs.
icois the PDA address of ICO Pot
Get all created ICO Pots.
owneris option to filter by ICO Pot owner addressico_mintis option to filter by ICO token mintcost_mintis option to filter by cost token mint
Get a user purchase PDA info.
user_purchaseis PDA address of user purchase
Get all user purchases info.
buyeris option to filter by the buyer addressicois option to filter by the ICO Pot address
For the FE side web3 integration, the scripts in lib directory can be use without no change.
The only thing the FE dev should change is providing web3 connection & the anchor program object from idl.
There is the code part for the keypair wallet based cli environement case in cli/scripts.
Should configure properly in BROWSER environment.
Deployed program on devnet: 373N2AQZikw4v5w1dq2TrWdQDRh87jhj93zBdGH25CVX
Attached tested commands and snapshot of the CLI results.
Check command.md file!