1/5
## AI Prompting for Smart Contracts AI can be extremely helpful when dealing with smart contract code, and we'll be looking at how it can be used in this lesson. The first thing we can do is use an AI to help explain what we are looking at, particularly if we're confused. Let's look at an example: ```python @external @view def get_price() -> int256: price_feed: AggregatorV3Interface = AggregatorV3Interface(0x69444A1769357215DEA6AC081bf1f130939a0dC25306) # ABI # Address return staticcall(price_feed.latestAnswer(), []) ``` If we're unsure about what the `staticcall` keyword is doing, we can copy that line of code and paste it into the AI of our choice. For this example we'll be using Claude. We'll add some context around the code and ask our AI to explain it to us. Here's an example of what we might ask Claude: ```` Hi, I have this function: ```python @external @view def get_price() -> int256: price_feed: AggregatorV3Interface = AggregatorV3Interface(0x69444A1769357215DEA6AC081bf1f130939a0dC25306) # ABI # Address return staticcall(price_feed.latestAnswer(), []) ```` This is in my Vyper smart contract. I don't understand what the `staticcall` keyword is doing. Can you help explain it to me? ```` Claude will then give us an explanation of what the keyword does, which can help us to better understand this part of our smart contract. We can also ask Claude to write some code for us, so we can avoid having to type it all ourselves, and this can be especially helpful when we are working with more complex code. If we have a smart contract that is already written and we're looking at how it's currently being used, we can ask Claude to write a new function that takes that code, restructures it, and makes it safe for our use. For example, if we have the following function: ```python @external def set_price(price: int256): price_feed: AggregatorV3Interface = AggregatorV3Interface(0x69444A1769357215DEA6AC081bf1f130939a0dC25306) # ABI # Address price_feed.setLatestAnswer(price) ```` We can copy this function, paste it into Claude and ask: ```` Hi Claude, this function: ```python @external def set_price(price: int256): price_feed: AggregatorV3Interface = AggregatorV3Interface(0x69444A1769357215DEA6AC081bf1f130939a0dC25306) # ABI # Address price_feed.setLatestAnswer(price) ```` This is in my Vyper smart contract. I would like to make it so that this function can be called by a `staticcall`. Can you help me write a new function that does that? ``` Claude will then write a new function that takes the existing code, restructures it, and uses the `staticcall` keyword so that it is safe for our use. As we progress through this course, we will be learning a lot about smart contracts, but often the hardest part is knowing when to ask for help. We'll be doing everything in our power to avoid that! ```
A comprehensive guide to understanding staticcall in Vyper smart contracts. Learn how staticcall works, why it's beneficial for gas efficiency and security, and when you should use staticcall in different scenarios.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
The basics of blockchain transactions, how to send and receive money on a blockchain network.
How to write Python based smart contracts using Vyper.
How to read and understand Vyper smart contracts.
Vyper data structures, arrays, structs, hash maps.
How to build a smart contract application and deploy on ZKsync with Moccasin.
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 engineer, educator, and Cyfrin co-founder. Patrick's smart contract development and security courses have helped hundreds of thousands of engineers kickstarting their careers into web3.
Last updated on April 21, 2025
Duration: 2h 08min
Duration: 2h 32min
Duration: 24min
Course Overview
About the course
The basics of blockchain transactions, how to send and receive money on a blockchain network.
How to write Python based smart contracts using Vyper.
How to read and understand Vyper smart contracts.
Vyper data structures, arrays, structs, hash maps.
How to build a smart contract application and deploy on ZKsync with Moccasin.
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 engineer, educator, and Cyfrin co-founder. Patrick's smart contract development and security courses have helped hundreds of thousands of engineers kickstarting their careers into web3.
Last updated on April 21, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar