Git Product home page Git Product logo

bonsai-banks's Introduction

Bonsai Banks

Tradeable Savings Accounts featuring evolving digital artwork and game-mechanisms to incentivize saving.

Overview

  • Bonsai Banks are bonsai NFT artworks that must be tended to using on-chain transactions
  • Each Bonsai Bank...
    • is minted by the botanist or contract owner
    • must be watered by depositing 20 DAI into the bank every 7 days
    • must be fertilized by depositing 0.02 ETH into the bank every 30 days
    • can wilt if watering is more than 7 days late and 5% of the deposits will go to the botanist
    • can grow if taken care of correctly for 90 days the botanist will make an enhancement to the bonsai art
    • must be destroyed to recover the deposits plus an interest earned

Protocol Specification

Parameters

  • address botanist - The owner of the contract and the producer of the artworks
  • BonsaiBank[] bonsaiBanks - A list of all the bonsai banks indexable using bonsaiIds
  • address waterToken - The token used to water the plant
  • address fertToken - The token used to fertilize a plant
  • uint256 waterAmount - The amount of waterToken needed to water the plant
  • uint256 fertAmount - The amount of fertToken needed to fertilize the plant
  • uint256 waterRate - The duration in seconds to wait between waterings
  • uint256 fertRate - The duration in seconds to wait between fertilizings

Structures

  • BonsaiBank
    • uint256 lastWatered - The unix timestamp when the plant was last watered
    • uint256 consecutiveWaterings - The number of consecutive waterings
    • uint256 lastFertilized - The unix timestamp when the plant was last fertilized
    • uint256 consecutiveFertilizings - The number of consecutive fertilizings
    • uint265 bonsaiId - The id of this BonsaiBank, used as the token ID for NFTs
    • string[] bonsaiUris - A list of all the images in cronological order for this BonsaiBank
    • int lifeStage - An index into bonsaiUris and references the plants current image URI
    • mapping(address => uint265) balances - A mapping of token addresses to amounts deposited to the Bonsai bank

Modifiers

  • onlybotanist - modifies methods so they can only be called by botanist

Methods

mint(address caretaker, string bonsaiURI)

  • Parameters
    • caretaker - The address this bonsai is minted to
    • bonsaiURI - the URI associated with the minted bonsai
  • Pre-conditions
    • None
  • Post-conditions
    • 1 BNZI is transferred to caretaker

water(uint256 bonsaiId)

  • Parameters
    • bonsaiId - The id of the bonsai to water
  • Pre-conditions
    • Must approve waterAmount amount of waterToken
  • Post-conditions
    • Transfer waterAmount amount of waterToken to the BonsaiBank
    • Resets lastWatered timestamp
    • Increments consecutiveFertilizings
    • balances is increased to reflect the deposit

fertilize(uint256 bonsaiId)

  • Parameters
    • bonsaiId - The id of the bonsai to fertilize
  • Pre-conditions
    • Must approve fertAmount amount of fertToken
  • Post-conditions
    • Transfer fertAmount amount of fertToken to the BonsaiBank
    • Resets lastFertilized timestamp
    • Increments consecutiveFertilizings
    • balances is increased to reflect the deposit

grow(uint256 bonsaiId, string bonsaiUri) onlybotanist

  • Parameters
    • bonsaiId - The id of the bonsai to water
    • bonsaiUri - The id of the new image for the plant
  • Pre-conditions
    • The bonsai has 12 consecutive waterings and 3 consecutive fertilizing
  • Post-conditions
    • The new bonsaiURI is added to the bonsaiUris
    • The lifeStage is incremented by 1
    • consecutiveWaterings and consecutiveFertilizings are reset

wilt(uint256 bonsaiId) onlybotanist

  • Parameters
    • bonsaiId - The id of the bonsai to wilt
    • bonsaiUri - The id of the new image for the plant
  • Pre-conditions
    • It has been waterRate * 2 seconds since the last watering
  • Post-conditions
    • 5% of all balances for this bonsai are slashed and set to the botanist
    • consecutiveWaterings and consecutiveFertilizings are reset

destroy(uint256 bonsaiId)

  • Parameters
    • bonsaiId - The id of the bonsai to destroy
  • Pre-conditions
    • The message sender is the holder of the bonsai
  • Post-conditions
    • The NFT is burned and all balances are sent to the message sender

bonsai-banks's People

Contributors

iamsahu avatar mikeghen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.