Blockchain Code Snippets

A high-quality educational dataset of blockchain and cryptography programming challenges. Each task includes a detailed problem statement, constraints, security notes, and complete solutions in 7 programming languages with English explanations.

Explore Challenges

Latest Challenges

Test your skills with these blockchain and cryptography tasks

Feb 28, 2020 Wallets Intermediate

W-20200228: Wallets

Create a simple command-line cryptocurrency wallet that can generate new addresses, sign transactions, and send coins to other addresses on a test blockchain network. The wallet should be able to stor...

public and private keys transaction signing blockchain basics
View Solutions →
Feb 27, 2020 Crypto Core Intermediate

CC-20200227: Crypto Core

Design and implement a simple digital signature system for verifying messages. Your system should allow a user to sign a message with their private key, and anyone else to verify that signature using ...

hash functions public key cryptography digital signatures
View Solutions →
Feb 26, 2020 Smart Contracts Intermediate

SC-20200226: Smart Contracts

Create a simple lottery smart contract where users can buy tickets by sending Ether. Each ticket costs a predefined amount of Ether (e.g., 0.1 ETH). The smart contract should allow one user to draw th...

Solidity basics Events Reentrancy attack
View Solutions →
Feb 25, 2020 Security Intermediate

S-20200225: Security

You are tasked with auditing a simple Ether Wallet smart contract written in Solidity. Your goal is to identify potential security flaws, particularly focusing on reentrancy attacks, and propose solut...

reentrancy attack smart contract vulnerabilities solidity programming
View Solutions →
Feb 24, 2020 Merkle Trees Intermediate

MT-20200224: Merkle Trees

You are tasked with implementing a simplified Merkle Tree structure in Python. Your implementation should include methods to add data elements, compute the root hash of the tree, and verify if a speci...

hash functions binary trees data integrity
View Solutions →
Feb 23, 2020 Merkle Trees Intermediate

MT-20200223: Merkle Trees

You are tasked with implementing a simple Merkle Tree for a list of transaction hashes in a blockchain system. A Merkle Tree is a binary tree in which every leaf node is labeled with the hash of a dat...

Hash Functions Data Integrity Efficient Data Verification
View Solutions →
Feb 22, 2020 DeFi Intermediate

DF-20200222: DeFi

Design and implement a simple decentralized exchange (DEX) smart contract on the Ethereum blockchain that allows users to swap two ERC20 tokens. The DEX should include functionalities for adding/remov...

smart contracts ERC20 tokens liquidity pools
View Solutions →
Feb 21, 2020 DeFi Intermediate

DF-20200221: DeFi

You are tasked with developing a simple decentralized exchange (DEX) where users can swap two ERC-20 tokens: TokenA and TokenB. Your DEX will include a liquidity pool that allows users to add or remov...

smart contracts liquidity pools ERC-20 tokens
View Solutions →
Feb 20, 2020 NFT Intermediate

NFT-20200220: NFT

You are tasked with creating a simple ERC-721 compliant smart contract for an NFT collection representing unique digital art pieces. Your contract should include functionalities to mint new NFTs, tran...

ERC-721 Smart Contracts Minting Gas Optimization
View Solutions →
Feb 19, 2020 Consensus Intermediate

C-20200219: Consensus

Design and implement a simple Proof of Work (PoW) algorithm for a blockchain network. Your task is to create a Python function that simulates the mining process by finding a nonce such that the hash o...

Proof of Work Blockchain Basics Hash Functions
View Solutions →
Feb 18, 2020 Cryptography Primitives Intermediate

CP-20200218: Cryptography Primitives

You are tasked with creating a simple digital signature system using SHA-256 as the hash function and RSA for signing. Your program should allow users to generate an RSA key pair, sign a message with ...

Hash Functions Digital Signatures
View Solutions →
Feb 17, 2020 Crypto Core Intermediate

CC-20200217: Crypto Core

You are tasked with developing a simple digital signature system for verifying the authenticity of messages. Your system should use asymmetric cryptography, specifically RSA key pairs to sign and veri...

Hash Functions Digital Signatures Public Key Cryptography
View Solutions →
Feb 16, 2020 Token Standards Intermediate

TS-20200216: Token Standards

You are tasked with creating a custom ERC-20 token named \"EduCoin\" on the Ethereum blockchain. Your EduCoin should have the following features: 1. The total supply of EduCoin is limited to 1,000,000...

ERC-20 standard smart contracts token minting and burning
View Solutions →
Feb 15, 2020 Cryptography Primitives Intermediate

CP-20200215: Cryptography Primitives

You are tasked with implementing a simple blockchain in Python that uses SHA-256 as its hash function. Your blockchain will consist of blocks, each containing an index, timestamp, data, previous hash,...

Hash Functions Collision Resistance
View Solutions →
Feb 14, 2020 Security Intermediate

S-20200214: Security

You are tasked with developing a simple Ethereum smart contract for a decentralized charity fund. The contract allows users to donate Ether, and the owner of the contract can withdraw funds to help th...

Reentrancy Attack Smart Contract Security Solidity Best Practices
View Solutions →
Feb 13, 2020 Smart Contracts Intermediate

SC-20200213: Smart Contracts

You are tasked with developing a simple ERC20 token contract for a new cryptocurrency called EduCoin. The contract should allow users to mint tokens, transfer them between addresses, and check balance...

Solidity ERC20 Token Standard Reentrancy Attack
View Solutions →
Feb 12, 2020 Merkle Trees Intermediate

MT-20200212: Merkle Trees

You are tasked with implementing a simplified version of a Merkle Tree. A Merkle Tree is a binary tree in which each non-leaf node is the hash of its two children, and the leaves contain hashes of dat...

Hash Functions Tree Structures Data Integrity
View Solutions →
Feb 11, 2020 Token Standards Intermediate

TS-20200211: Token Standards

Create a custom ERC-20 token named 'EduCoin' that includes the following functionalities: 1. The contract should have a mint function accessible only by the contract owner to issue tokens. 2. Implemen...

ERC-20 Smart Contracts Solidity
View Solutions →
Feb 10, 2020 Wallets Intermediate

W-20200210: Wallets

You are tasked with developing a simple cryptocurrency wallet application. Your wallet should be capable of generating new addresses, storing private keys securely, and sending transactions to the blo...

private keys management transaction signing blockchain network interaction
View Solutions →
Feb 9, 2020 Smart Contracts Intermediate

SC-20200209: Smart Contracts

You are tasked with developing a simple decentralized lottery smart contract using Solidity. This contract should allow users to enter the lottery by paying an entry fee, and one winner will be random...

Solidity basics Events in Solidity Reentrancy attacks
View Solutions →
Feb 8, 2020 Wallets Intermediate

W-20200208: Wallets

You are tasked with developing a simplified cryptocurrency wallet application that can generate new addresses, store private keys securely, and sign transactions. Your wallet should be able to handle ...

Blockchain fundamentals Public and Private Keys Digital Signatures
View Solutions →
Feb 7, 2020 Cryptography Primitives Intermediate

CP-20200207: Cryptography Primitives

Design and implement a simple digital signature system using asymmetric cryptography. Your task is to create two programs: one for signing messages with a private key, and another for verifying signat...

Hash Functions Digital Signatures Public Key Cryptography
View Solutions →
Feb 6, 2020 Cryptography Primitives Intermediate

CP-20200206: Cryptography Primitives

Implement a simple proof-of-work (PoW) algorithm in Python. The goal is to find a nonce that, when concatenated with a given string and then hashed using SHA-256, produces a hash starting with at leas...

Hash Functions Collision Resistance Nonce
View Solutions →
Feb 5, 2020 Security Intermediate

S-20200205: Security

In this task, you are given a simplified version of an Ethereum smart contract that is supposed to manage user deposits and withdrawals. Your goal is to identify the security vulnerability present in ...

smart contract vulnerabilities reentrancy attacks solidity best practices
View Solutions →
Feb 4, 2020 Wallets Intermediate

W-20200204: Wallets

You are tasked with developing a simple blockchain wallet application that can generate a new wallet (a pair of public and private keys), sign transactions, and display the address associated with the...

public key cryptography private key management transaction signing
View Solutions →
Feb 3, 2020 DeFi Intermediate

DF-20200203: DeFi

You are tasked with developing a simple decentralized liquidity pool for an ERC20 token called "CryptoCoin". The liquidity pool will allow users to deposit and withdraw their CryptoCoins in exchange f...

smart contracts ERC20 tokens liquidity pools
View Solutions →
Feb 2, 2020 NFT Intermediate

NFT-20200202: NFT

You are tasked with creating a simple ERC-721 compliant non-fungible token (NFT) smart contract on the Ethereum blockchain. Your NFT will represent unique digital art pieces that can be bought, sold, ...

ERC-721 standard Smart Contracts Minting NFTs
View Solutions →
Feb 1, 2020 Security Intermediate

S-20200201: Security

You are tasked with securing a simple Ethereum smart contract designed for a decentralized lottery system. The current implementation is vulnerable to reentrancy attacks, which can allow attackers to ...

reentrancy attack smart contract vulnerabilities solidity best practices
View Solutions →
Jan 31, 2020 Smart Contracts Intermediate

SC-20200131: Smart Contracts

You are tasked with creating a simple voting smart contract for an organization's general meeting. The contract should allow the chairperson to add voters, and each voter can cast one vote for one of ...

Solidity Events Modifiers
View Solutions →
Jan 30, 2020 Smart Contracts Intermediate

SC-20200130: Smart Contracts

You are tasked with creating a simple smart contract that simulates a basic lottery system. The contract should allow users to participate by sending an amount of Ether, and the winner will be selecte...

Solidity basics Events in Ethereum Reentrancy attacks
View Solutions →
Jan 29, 2020 Security Intermediate

S-20200129: Security

You are tasked with developing a smart contract for an Ethereum-based token exchange platform. The contract should allow users to deposit and withdraw Ether, as well as trade tokens. However, during t...

Smart Contract Vulnerabilities Reentrancy Attack
View Solutions →
Jan 28, 2020 Cryptography Primitives Intermediate

CP-20200128: Cryptography Primitives

Design a simple digital signature scheme using hash functions and symmetric encryption. Your task is to create a function that takes a message, a secret key, and produces a digital signature. The digi...

hash functions message authentication codes (MAC) symmetric encryption
View Solutions →
Jan 27, 2020 Consensus Intermediate

C-20200127: Consensus

In this task, you will develop a simple blockchain simulation using the Proof of Stake (PoS) consensus mechanism. Your system should allow for validator registration and selection based on their stake...

Proof of Stake Validator Selection Blockchain Transactions
View Solutions →
Jan 26, 2020 Security Intermediate

S-20200126: Security

You are tasked with auditing a simple Solidity smart contract designed for a decentralized lottery system. The contract allows users to enter by sending Ether and has a function to distribute the priz...

smart contract vulnerabilities reentrancy attack solidity programming
View Solutions →
Jan 25, 2020 Smart Contracts Intermediate

SC-20200125: Smart Contracts

You are tasked with developing a simple voting smart contract using Solidity. This contract should allow voters to cast their votes for one of three predefined candidates. Each voter is allowed to vot...

Solidity basics Event emission Transaction handling
View Solutions →