├── IIIT Delhi Workshop ├── README.md └── vyperverse-delhi.vy /IIIT Delhi Workshop: -------------------------------------------------------------------------------- 1 | # @version 0.4.1 2 | #pragma evm-version cancun 3 | 4 | event FavoriteNumberSet: 5 | user: indexed(address) 6 | number: uint256 7 | 8 | event FavoritePersonSet: 9 | user: indexed(address) 10 | person: indexed(address) 11 | 12 | event ContractWithdrawal: 13 | amount: uint256 14 | 15 | favorite_numbers: public(HashMap[address, uint256]) 16 | favorite_people: public(HashMap[address, address]) 17 | owner: public(address) 18 | 19 | @deploy 20 | def __init__(): 21 | self.owner = msg.sender 22 | self.favorite_numbers[msg.sender] = 42 23 | log FavoriteNumberSet(user=msg.sender, number=42) 24 | 25 | @external 26 | @payable 27 | def donate(): 28 | pass 29 | 30 | @external 31 | def set_number(new_number: uint256): 32 | assert new_number > 0, "Invalid number" 33 | self.favorite_numbers[msg.sender] = new_number 34 | log FavoriteNumberSet(user=msg.sender, number=new_number) 35 | 36 | @external 37 | def set_person(person_address: address): 38 | assert person_address != empty(address), "Invalid address" 39 | self.favorite_people[msg.sender] = person_address 40 | log FavoritePersonSet(user=msg.sender, person=person_address) 41 | 42 | @external 43 | @view 44 | def check_number_match(other_user: address) -> bool: 45 | return self.favorite_numbers[msg.sender] == self.favorite_numbers[other_user] 46 | 47 | @external 48 | def withdraw(): 49 | assert msg.sender == self.owner, "Unauthorized" 50 | balance: uint256 = self.balance 51 | send(msg.sender, balance) 52 | log ContractWithdrawal(amount=balance) 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Vyper Workshop Contract Delhi 4 | 5 | A beginner-friendly smart contract template for learning Vyper development. **Deploy on any EVM chain** using Remix IDE! 6 | 7 | --- 8 | 9 | ## Features ✨ 10 | - Store favorite numbers/people 11 | - Donation functionality 12 | - Withdraw funds (owner only) 13 | - **Your Custom Intro & Feedback** (mandatory!) 14 | - Works on multiple EVM chains 15 | 16 | --- 17 | 18 | ## Prerequisites ✅ 19 | 1. [MetaMask](https://metamask.io/) installed 20 | 2. Testnet tokens (get from faucets below ⬇️) 21 | 22 | --- 23 | 24 | ## Deployment Steps 🛠️ 25 | 26 | ### 1. Open Remix IDE 27 | Visit [Remix IDE](https://remix.ethereum.org) in your browser. 28 | 29 | --- 30 | 31 | ### 2. Create a New File 32 | 1. In the **File Explorer**, click `+` to create a new file. 33 | 2. Name it `Favorites.vy`. 34 | 3. Copy-paste the contract code into the file. 35 | 36 | --- 37 | 38 | ### 3. Customize the Contract 39 | Before deploying, replace the placeholders in the contract with your personal details: 40 | ```python 41 | # ---------------------- USER CUSTOMIZATION START ---------------------- 42 | user_intro: public(String[50]) = "YOUR_INTRODUCTION_HERE" 43 | # Example: "Web3 developer from Berlin building DeFi projects" 44 | 45 | user_feedback: public(String[100]) = "YOUR_FEEDBACK_HERE" 46 | # Example: "Excellent workshop! Learned Vyper best practices and deployment." 47 | # ----------------------- USER CUSTOMIZATION END ----------------------- 48 | ``` 49 | ❗ **Mandatory**: You must replace `YOUR_INTRODUCTION_HERE` and `YOUR_FEEDBACK_HERE` before deploying. 50 | 51 | --- 52 | 53 | ### 4. Compile the Contract 54 | 1. Go to the **Solidity Compiler** tab (yes, it works for Vyper too!). 55 | 2. Select **Vyper Compiler** from the dropdown. 56 | 3. Set the compiler version to `0.4.1`. 57 | 4. Click **Compile Favorites.vy**. 58 | 59 | --- 60 | 61 | ### 5. Deploy to a Testnet 62 | 1. Go to the **Deploy & Run Transactions** tab. 63 | 2. Select **Injected Provider - MetaMask** as your environment. 64 | 3. Ensure MetaMask is connected to your desired testnet: 65 | - Celo Testnet: [RPC URL](https://alfajores-forno.celo-testnet.org) 66 | - Monad Testnet: [RPC URL](https://testnet-rpc.monad.xyz) 67 | - Berachain Testnet: [RPC URL](https://testnet-rpc.berachain.com) 68 | - Ethereum Sepolia: [RPC URL](https://rpc.sepolia.org) 69 | 70 | 4. Click **Deploy**, confirm the transaction in MetaMask, and wait for it to be mined. 71 | 72 | --- 73 | 74 | ### 6. Get Testnet Tokens 💧 75 | | Network | Faucet Link | 76 | |-------------|--------------------------------------| 77 | | Celo | https://faucet.celo.org/ | 78 | | Monad | https://faucet.monad.xyz | 79 | | Berachain | https://faucet.berachain.com | 80 | | Ethereum | https://sepoliafaucet.com | 81 | 82 | --- 83 | 84 | ### 7. Verify Your Contract ✅ 85 | 1. After deployment, copy your contract address. 86 | 2. Visit chain explorer: 87 | - Celo: https://explorer.celo.org/alfajores 88 | - Monad: https://testnet-explorer.monad.xyz 89 | - Berachain: https://testnet-scan.berachain.com 90 | - Ethereum Sepolia: https://sepolia.etherscan.io 91 | 92 | 3. Verify with: 93 | - Contract code (copy from `Favorites.vy`) 94 | - Compiler version: 0.4.1 95 | - EVM version: Cancun 96 | 97 | --- 98 | 99 | ## Customization Guide 🎨 100 | 101 | ### Mandatory Changes (For Proof of Work) 102 | ``` 103 | # In Favorites.vy: 104 | user_intro: public(String[50]) = "Your intro here" 105 | user_feedback: public(String[100]) = "Your feedback here" 106 | ``` 107 | ❗ Contract won't deploy until you add these! 108 | 109 | ### Optional Changes 110 | ``` 111 | # Change default favorite number (Line 31) 112 | self.favorite_numbers[msg.sender] = 42 # ← Change 42 to your lucky number 113 | ``` 114 | 115 | --- 116 | 117 | ## Need Help? 🤔 118 | 119 | Common Issues: 120 | 1. **Transaction Stuck?** Increase gas price in MetaMask. 121 | 2. **Verification Failed?** Double-check compiler version. 122 | 3. **No Funds?** Wait 5 mins after using faucet. 123 | 124 | --- 125 | 126 | ## License & Attribution 📜 127 | 128 | This smart contract development workshop was designed and led by [Prakhar Tripathi](https://x.com/he2plus), India, as part of the Web3 Developer Workshop Series. 129 | 130 | ``` 131 | SPDX-License-Identifier: MIT 132 | ``` 133 | 134 | --- 135 | 136 | ## Contribute 🙌 137 | 138 | Found an issue or want to improve this template? Fork this repo and submit PRs to: 139 | `https://github.com/he2plus/vyper-workshop-delhi` 140 | 141 | --- 142 | 143 | This README ensures users can easily deploy your contract on Remix IDE across multiple EVM-compatible blockchains while leaving attribution and proof of work intact! 🚀 144 | 145 | --- 146 | Answer from Perplexity: pplx.ai/share 147 | -------------------------------------------------------------------------------- /vyperverse-delhi.vy: -------------------------------------------------------------------------------- 1 | # @version 0.4.1 2 | #pragma evm-version cancun 3 | 4 | # ============================================================== 5 | # This smart contract development workshop was designed and lead 6 | # by Prakhar Tripathi [https://x.com/he2plus], India 7 | # ============================================================== 8 | 9 | # ---------------------- USER CUSTOMIZATION START ---------------------- 10 | # >>> REQUIRED: Replace below with your personal introduction (max 50 chars) 11 | user_intro: public(String[50]) = "YOUR_INTRODUCTION_HERE" 12 | # Example: "Web3 developer from Berlin building DeFi projects" 13 | 14 | # >>> REQUIRED: Replace below with your feedback (max 100 chars) 15 | user_feedback: public(String[100]) = "YOUR_FEEDBACK_HERE" 16 | # Example: "Excellent workshop! Learned Vyper best practices and deployment." 17 | # ----------------------- USER CUSTOMIZATION END ----------------------- 18 | 19 | event FavoriteNumberSet: 20 | user: indexed(address) 21 | number: uint256 22 | 23 | event FavoritePersonSet: 24 | user: indexed(address) 25 | person: indexed(address) 26 | 27 | event ContractWithdrawal: 28 | amount: uint256 29 | 30 | favorite_numbers: public(HashMap[address, uint256]) 31 | favorite_people: public(HashMap[address, address]) 32 | owner: public(address) 33 | 34 | @deploy 35 | def __init__(): 36 | # Validate user customization 37 | assert len(self.user_intro) > 0, "Add your introduction!" 38 | assert len(self.user_feedback) > 0, "Add your feedback!" 39 | 40 | # Original contract logic 41 | self.owner = msg.sender 42 | self.favorite_numbers[msg.sender] = 42 43 | log FavoriteNumberSet(user=msg.sender, number=42) 44 | 45 | @external 46 | @payable 47 | def donate(): 48 | pass 49 | 50 | @external 51 | def set_number(new_number: uint256): 52 | assert new_number > 0, "Invalid number" 53 | self.favorite_numbers[msg.sender] = new_number 54 | log FavoriteNumberSet(user=msg.sender, number=new_number) 55 | 56 | @external 57 | def set_person(person_address: address): 58 | assert person_address != empty(address), "Invalid address" 59 | self.favorite_people[msg.sender] = person_address 60 | log FavoritePersonSet(user=msg.sender, person=person_address) 61 | 62 | @external 63 | @view 64 | def check_number_match(other_user: address) -> bool: 65 | return self.favorite_numbers[msg.sender] == self.favorite_numbers[other_user] 66 | 67 | @external 68 | def withdraw(): 69 | assert msg.sender == self.owner, "Unauthorized" 70 | balance: uint256 = self.balance 71 | send(msg.sender, balance) 72 | log ContractWithdrawal(amount=balance) 73 | --------------------------------------------------------------------------------