Inspiration

I wanted to build and deploy my first smart contract and learn about brownie and solidity

What it does

It's a simple savings account smart contract. The features are the following:

  1. The contract is assigned a target date
  2. Anyone can fund the contract
  3. The owner can withdraw funds at any time if the ETH price has increased and there'd be a net profit. If this isn't the case, the owner must wait until the target date to withdraw funds.

How we built it

I used python, solidity (brownie) and pytest

Challenges we ran into

Getting the current date in solidity (which had to be mocked in the tests with a mock contract) and calculating the break even price for all the fundings of the contract (based on the ethereum price at the time of each funding), which was more complicated than I first thought.

Accomplishments that we're proud of

Tested and deployed my first smart contract and escaped tutorial hell!

What we learned

Learned about using brownie, testing on a development network, configuring a brownie project to use different networks and also using chainlink price feeds

What's next for Smart Contract For Newbies

Currently the owner can withdraw funds before the target date if the price of ethereum is higher than the average of all the prices for each funding (meaning that there would be a profit). A nice extension for this feature would be to require a minimum profitability to withdraw funds e.g. ETH price must have increased by 15%

Built With

Share this project:

Updates