1/5
## Deployment Parameterization We're back to our code base. We now have this `get_price` function which we are actually going to comment out. Again, I'm using command forward slash as a keyboard shortcut for this because we are not actually going to use this. But what we are going to do is we're going to create this `get_eth_to_usd_rate` function. We just learned how to get the price from a chain price feed. This is really exciting. We're only going to use this one price feed in this entire contract. We are going to make the price feed a state variable, up at the top. Since our structs are the same as in the last lesson, the `AggregatorV3Interface` is a new type. We can create a variable, a state variable, or a storage variable, called `price_feed` of type `AggregatorV3Interface`. In our deploy function we can say `self.price_feed = AggregatorV3Interface()` at address. We are hardcoding this address into the contract. We can add a comment saying that we are using the Sepolia testnet: ```python # Sepolia ``` We should instead add the address as a parameter. We can do this with the following code: ```python @external def deploy(price_feed_address: address): self.minimum_usd = 5 self.price_feed = AggregatorV3Interface(price_feed_address) ``` The deploy function now has an input for the price feed address. Now that we have our `price_feed` object, we can scroll down to our `get_eth_to_usd_rate` function. We will make the price variable equal to `staticcall self.price_feed.latestAnswer()`. ```python @internal def get_eth_to_usd_rate(): price: int256 = staticcall(self.price_feed.latestAnswer()) ``` This way, right when we deploy our contract, we can parameterize the address that we want to use. This is a much cleverer way than hard coding it in.
A practical guide to deployment parameterization in Vyper using Remix IDE. The lesson covers how to create a state variable to store a price feed address and pass it as a parameter during deployment, allowing for flexible and dynamic pricing in smart contracts.
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