This is token presale smart contract. This is full-working project. As a novice of solana smart contract, it might be one of good source code for you. Feel free to reach out of me if you have any question or custom requirements[telegram: https://t.me/DevCutup or whatsapp: https://wa.me/13137423660].
-
Install
nodeandyarn -
Install
rust,solanaandanchor
First of all, you have to clone this repo to your PC.
In the folder token-presale
-
Install node modules using
yarn -
Build program using anchor cli
anchor build -
Get program address using solana cli.
solana-keygen pubkey ./target/deploy/presale-keypair.jsonYou can get the pubkey of the program. e.g.
BE4G...5qhv -
Change program address in the code to
BE4G...5qhvin
lib.rsdeclare_id!("BE4G...5qhv");in
Anchor.tomlpresale = "BE4G...5qhv" -
Change provider settings in
Anchor.tomlcluster = "localnet" wallet = "./admin.json" -
run
anchor buildagain -
deploy program using anchor cli
anchor deploy
./tests/presal.ts is test script for each instruction
run anchor test to check test the smart contract
You should build and deploy on devnet first.
Check the program address and USDC, USDT address.
yarn script init -t <TOKEN_ADDRESS>
e.g. yarn script init -t 5U6PVxcjCWo361vFwS6cfB65Br4T5jECA6vsVAtm5urt
yarn script set-vault -v <DAO_WALLET_ADDRESS>
e.g. yarn script set-vault -v DJDcV3UxP55KqHUKsTSBve7xssRYtbQ5eSG8uWND2HQ7
yarn script deposit-token -t <TOKEN_ADDRESS> -a <DEPOSIT_ADMOUNT>
e.g. yarn script deposit-token -t 5U6PVxcjCWo361vFwS6cfB65Br4T5jECA6vsVAtm5urt -a 200000000000000
yarn script start-presale -t <TOKEN_ADDRESS>
e.g. yarn script start-presale -t 5U6PVxcjCWo361vFwS6cfB65Br4T5jECA6vsVAtm5urt
yarn script set-stage -s <STAGE_NUMBER>
e.g. yarn script set-stage -s 1
- Telegram: https://t.me/DevCutup
- Whatsapp: https://wa.me/13137423660
- Twitter: https://x.com/devcutup