November 2, 2026

How To Code A Simple Ponzi in Ethereum’s Solidity – Dean Schmid

How To Code A Simple Ponzi in Ethereum’s Solidity – Dean Schmid

How To Code A Simple Ponzi in Ethereum’s Solidity – Dean Schmid

How To Code A Simple Ponzi in Ethereum’s Solidity – Dean Schmid
Koch burns another ignorant investor

A simple Ponzi will take new investor money and send it to the previous investors. As long as there are new investors, and there is always more money going into the contract, the previous investors will see a return on their investment. That is until our final investor get’s Koched.

pragma solidity ^0.5.0; 
contract Ponzi

First set up your contract

contract Ponzi 
function () payable public 

This means our fallback function is payable and “investors” can send money to it.

uint minimumInvestment = currentInvestment * 11 / 10;
require(msg.value > minimumInvestment);

When the contract is created the minimum investment is 10% > 0.

On line 5, current investment is reset to the msg.value. The current investment will continue to increase by a minimum of 10% as more money is added to the contract.

Line 2 has a require statement which will exit the function is the msg.value isn’t greater than the minimum investment. The minimum investment is set on line 1 as shown below.

uint minimumInvestment = currentInvestment * 11 / 10;

There are no decimals in solidity. A fact you have to workaround.

x + 10% === x * 11 / 10.

require(msg.value > minimumInvestment);

When the require statement checks if msg.value is > minimum investment, it is really asking if the attempted new investment is 10% larger than the previous.

address previousInvestor = currentInvestor;

The first time this function is called the previous investor isn’t set to an address. Look at the next line then flick back to this.

currentInvestor = msg.sender;

The current investor will be set to the msg.sender the first time it is run, and in subsequent function calls this value will update the previous investor.

currentInvestment = msg.value;

Here the current investment is set to the value attached to the function call. Remember the first time the function is called, the current investment is set to 0. To satisfy the require statement on line 2 the first time the function is called any amount of ether can be sent into the contract.

previousInvestor.send(msg.value);

This will send the new investment to the old investor and keep the ponzi alive.

Published at Sun, 04 Aug 2019 02:48:25 +0000

Bitcoin Pic Of The Moment
✅ Marco Verch is a Professional Photographer and Speaker from Cologne. ? This image can be used under Creative Commons 2.0. Please link to the original photo and the license.
By marcoverch on 2017-11-09 16:02:41
tags

Previous Article

Mintable and ZB Exchange Collaborate to Gift NFTs to Meetup’s Participants

Next Article

vector/ai