1. Home
  2. /
  3. Vyper
  4. /
  5. Simple Bank (Deposit + Withdraw)

Simple Bank (Deposit + Withdraw) - Vyper Typing CST Test

Loading…

Simple Bank (Deposit + Withdraw) — Vyper Code

A tiny bank contract allowing users to deposit and withdraw ETH.

balances: public(HashMap[address, uint256])

@payable
@external
def deposit():
	self.balances[msg.sender] += msg.value

@external
def withdraw(amount: uint256):
	assert self.balances[msg.sender] >= amount
	self.balances[msg.sender] -= amount
	send(msg.sender, amount)

Vyper Language Guide

Vyper is a security-focused, Python-like smart contract programming language for the Ethereum Virtual Machine (EVM). It emphasizes simplicity, readability, and auditability-making it ideal for high-assurance smart contracts.

Primary Use Cases

  • ▸High-assurance smart contracts
  • ▸DeFi protocols and vaults
  • ▸Governance and treasury contracts
  • ▸Security-audited financial logic
  • ▸Minimalistic EVM dApps

Notable Features

  • ▸Python-like syntax
  • ▸Strong typing and safety checks
  • ▸No modifiers -> predictable flow
  • ▸No inheritance -> reduced complexity
  • ▸Built-in overflow/underflow protection

Origin & Creator

Vyper was created by the Ethereum Foundation with contributions from Vitalik Buterin and the research team. It emerged around 2017 as a safer alternative to Solidity.

Industrial Note

Vyper is heavily used in high-stakes DeFi protocols, DAO governance, staking pools, and security-critical Ethereum contracts where simplicity and predictability matter more than feature richness.

More Vyper Typing Exercises

Simple Counter ContractOwner-Only StorageERC20-Like Token (Minimal)Timestamp LockerSimple VotingWhitelist AccessEvent LoggerImmutable ConfigSimple Multiplier

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher