constCLAIM_AMOUNT:Int=1;constINIT_SUPPLY:Int=30000;messageUserStake{amount:Int;}messageUserWithdraw{amount:Int;}messageStakeEvent{sender:Address;amount:Int;}contractAirDrop{total_balance:Intasuint256;user_info:map<Address,Int>;user_claim_info:map<Address,Bool>;init(version:Int){self.user_info=emptyMap();self.total_balance=INIT_SUPPLY;}receive("AirDrop"){require(self.user_claim_info.get(sender())==null,"Have claimed");letuser_staked:Int=0;if(self.user_info.get(sender())!=null){user_staked=self.user_info.get(sender())!!;}self.total_balance=self.total_balance-CLAIM_AMOUNT;self.user_info.set(sender(),user_staked+CLAIM_AMOUNT);self.user_claim_info.set(sender(),true);}receive(msg:UserStake){require(context().value>msg.amount,"Incorrect TON value");letuser_staked:Int=0;if(self.user_info.get(sender())!=null){user_staked=self.user_info.get(sender())!!;}self.total_balance=self.total_balance+msg.amount;self.user_info.set(sender(),user_staked+msg.amount);}receive(msg:UserWithdraw){require(self.user_info.get(sender())!=null&&self.user_info.get(sender())!!!=0,"Nothing to withdraw");letuser_staked:Int=0;user_staked=self.user_info.get(sender())!!;require(msg.amount<=user_staked,"Insufficient balance");self.total_balance=self.total_balance-msg.amount;if(msg.amount==user_staked){self.user_info.del(sender());}else{self.user_info.set(sender(),user_staked-msg.amount);}}getfunbalance():Int{returnself.total_balance;}getfunis_solved():Bool{returnself.total_balance==0;}}
receive(msg:UserStake){require(context().value>msg.amount,"Incorrect TON value");letuser_staked:Int=0;if(self.user_info.get(sender())!=null){user_staked=self.user_info.get(sender())!!;}self.total_balance=self.total_balance+msg.amount;self.user_info.set(sender(),user_staked+msg.amount);}
import{Address,toNano,TonClient,WalletContractV4}from"@ton/ton";import{mnemonicToPrivateKey}from"ton-crypto";import{AirDrop}from"./output/Airdrop_AirDrop";import*asdotenvfrom"dotenv";dotenv.config();(async()=>{constclient=newTonClient({endpoint:"http://65.21.223.95:8081/jsonRPC",});letmnemonics=(process.env.mnemonics_2||"").toString();console.log(mnemonics);letkeyPair=awaitmnemonicToPrivateKey(mnemonics.split(" "));letsecretKey=keyPair.secretKey;letworkchain=0;// we are working in basechain.letdeployer_wallet=WalletContractV4.create({workchain,publicKey:keyPair.publicKey});console.log(deployer_wallet.address);letdeployer_wallet_contract=client.open(deployer_wallet);lettarget=Address.parse(CONTRACT);letcontract_open=awaitclient.open(AirDrop.fromAddress(target));awaitcontract_open.send(deployer_wallet_contract.sender(secretKey),{// deducting fees from itvalue:toNano("0.1"),},{"$$type":"UserStake","amount":-30000n,});})();