1/5
## Resetting a Dynamic Array We are looking to keep track of all the funders in our contract. We can set this up as a fixed-size array, but it is probably going to be better for us to use a dynamic array. Let's make this a public dynamic array of addresses with a max size of, let's say, 1,000. This means there will be a maximum of 1,000 addresses we can have as funders. If we have more funders, our contract will kind of break, but let's just hope that we don't get too many people who want to buy us coffee. We'll scroll down to our fund function and we'll keep track of this funder here, whoever funds us. We'll say: ```python self.funders.append(msg.sender) ``` So, we're going to say, hey, in our funders dynamic array, we'll just append, we'll just add to the list, the message.sender, whoever calls this fund function. Great, and then when we call withdraw, we probably want to reset the funders, maybe we don't, but I want to reset the funders every time I call withdraw. We can do this really easily with dynamic arrays which is part of the reason why I'm using a dynamic array. We can just say: ```python self.funders = [] ``` Boom! That's it. This is how you identify an empty array. So self.funders equals this, means it's an empty array, and it is essentially reset.
A simple guide to resetting a dynamic array in Vyper. This lesson covers how to identify an empty array, reset a dynamic array to an empty state, and use the append function in Vyper.
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