avatarAlex Roan

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

3418

Abstract

ey yet, but I’ve made 0.2ETH for doing nothing.</li><li>Charlie comes in with another 1ETH, this is where it gets interesting. I take my fee, and now the pot stands at 2.7ETH, enough to double Alice’s original investment.</li><li>Alice gets paid 2ETH, doubling her money, she cuts and runs. The pot stands at 0.7ETH.</li><li>Alice can’t believe that it worked, so she brings in her friend Dave who thinks hell yeah I’m doubling my money! Invests 3TH.</li><li>I take my fee, the pot now at 4.4ETH, both Bob and Charlie get paid their winnings and the pot stands at 0.4ETH.</li><li>And so on, and so on.</li></ol><h2 id="c9f1">Code</h2><p id="f8e0"><i>The full project for this code can be found <a href="https://github.com/alexroan/EthereumChainPonzi">here</a></i></p><div id="3e87"><pre><span class="hljs-attribute">pragma</span> solidity ^<span class="hljs-number">0</span>.<span class="hljs-number">5</span>.<span class="hljs-number">0</span>;</pre></div><div id="5d6f"><pre><span class="hljs-attribute">import</span> <span class="hljs-string">"<span class="hljs-variable">@openzeppelin</span>/contracts/math/SafeMath.sol"</span>;</pre></div><div id="7b15"><pre><span class="hljs-built_in">contract</span> Doubler {</pre></div><div id="dd31"><pre><span class="hljs-keyword">using</span> SafeMath <span class="hljs-keyword">for</span> <span class="hljs-built_in">uint</span>;</pre></div><div id="913f"><pre>address payable <span class="hljs-built_in">public</span> <span class="hljs-keyword">owner</span>;</pre></div><div id="0af0"><pre>struct <span class="hljs-keyword">User</span> <span class="hljs-title">{</span></pre></div><div id="5854"><pre>address payable addr<span class="hljs-comment">;</span></pre></div><div id="5b80"><pre>uint amount<span class="hljs-comment">;</span></pre></div><div id="1130"><pre>}</pre></div><div id="364e"><pre><span class="hljs-keyword">User</span>[] <span class="hljs-built_in">public</span> users;</pre></div><div id="e910"><pre>uint public currentlyPaying <span class="hljs-operator">=</span> <span class="hljs-number">0</span><span class="hljs-comment">;</span></pre></div><div id="efa9"><pre>uint public totalUsers <span class="hljs-operator">=</span> <span class="hljs-number">0</span><span class="hljs-comment">;</span></pre></div><div id="e25c"><pre><span class="hljs-function"><span class="hljs-keyword">constructor</span><span class="hljs-params">()</span> <span class="hljs-title">public</span> <span class="hljs-comment">{</span></span></pre></div><div id="5c22"><pre><span class="hljs-attribute">owner</span> <span class="hljs-operator">=</span> msg.sender<span class="hljs-comment">;</span></pre></div><div id="feb6"><pre>}</pre></div><div id="5903"><pre><span class="hljs-keyword">function</span> <span class="hljs-keyword">join</span>() <span class="hljs-keyword">external</span> payable{</pre></div><div id="980e"><pre>users.<span class="hljs-keyword">push</span>(<span class="hljs-literal">User</span>(msg.sender, msg.value))<span class="hljs-comment">;</span></pre></div><div id="866b"><pre><span class="hljs-attribute">totalUsers</span> += <span class="hljs-number">1</span>;</pre></div><div id="b65e"><pre><span class="hljs-keyword">owner</span>.transfer(msg.<span class="hljs-keyword">value</span>.div(<span class="hljs-number">10</span>));</pre></div><div id="fe6c"><pre>while (address(this)<span class="hljs-selector-class">.balance</span> > users<span c

Options

lass="hljs-selector-attr">[currentlyPaying]</span><span class="hljs-selector-class">.amount</span><span class="hljs-selector-class">.mul</span>(<span class="hljs-number">2</span>)) { users<span class="hljs-selector-attr">[currentlyPaying]</span><span class="hljs-selector-class">.addr</span><span class="hljs-selector-class">.transfer</span>(users[currentlyPaying].amount.mul(<span class="hljs-number">2</span>));</pre></div><div id="bb35"><pre><span class="hljs-attribute">currentlyPaying</span> += <span class="hljs-number">1</span>;</pre></div><div id="99ba"><pre>}</pre></div><div id="2792"><pre>}</pre></div><div id="0dc4"><pre>}</pre></div><p id="0b34">As you can see, this is a super easy contract to make.</p><p id="db6a">Every time a new investor joins the party, the <b><i>join() </i></b>function is called and performs the following:</p><ul><li>Adds the new user to the list of investors with the amount they invested.</li><li>Transfers 10% to the owner.</li><li>Pay as many of the early investors as possible using what’s in the pot.</li></ul><h1 id="003f">Conclusion</h1><p id="df20">DeFi is the word on everyone’s lips at the moment, and it’s easy to get caught up in the excitement. New protocols and products are popping up every few hours.</p><p id="539d">Fortunately for the more nefarious amongst us, times like these signal ripe opportunity to make a quick buck out of the less informed. This has famously happened in the past in the crypto sphere (if you don’t know what I’m talking about, google “Carlos Matos”).</p><p id="ed73">My prediction is that we will see a lot more “controversial” news about scams that ride on the coattails of the DeFi movement. Keep your wits about you, as they prey on our emotions and draw you in.</p><p id="b6b7"><b>If you liked this, read the next instalment on <a href="https://readmedium.com/ethereum-smart-contract-ponzi-schemes-part-2-2162fcd7ddc">Tree Shaped Ponzi Schemes on the Ethereum Network.</a></b></p><p id="4978"><i>This article was inspired by a paper entitled “<a href="https://arxiv.org/pdf/1703.03779.pdf">Dissecting Ponzi schemes on Ethereum: identification, analysis, and impact</a>” by Massimo Bartoletti, Salvatore Carta, Tiziana Cimoli, Roberto Saia.</i></p><h1 id="9c60">Learn More</h1><blockquote id="8974"><p><i>If you enjoyed this post and want to learn more about Smart Contract security, Blockchain Development or the Blockchain Space in general, I highly recommend signing up to the <a href="https://courses.blockgeeks.com/?ref=637"><b>Blockgeeks platform</b></a>. They have courses on a wide range of topics in the industry, from Coding to Marketing to Trading. It has proven to be an invaluable tool for my development in the Blockchain space.</i></p></blockquote><div id="af9e" class="link-block"> <a href="https://readmedium.com/blockchain-development-resources-b44b752f3248"> <div> <div> <h2>Blockchain Development Resources To Follow Right Now</h2> <div><h3>A list of resources to learn Blockchain, Ethereum, and DApp development</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*GZlVe27SOc44fcIYztY5Qw.jpeg)"></div> </div> </div> </a> </div></article></body>

Ethereum Smart Contract Ponzi Schemes

A New Frontier For The Notorious Pyramid Scheme

Photo by Andy Li on Unsplash

What Is A Ponzi Scheme

“A Ponzi scheme is a fraudulent investing scam promising high rates of return with little risk to investors. The Ponzi scheme generates returns for early investors by acquiring new investors. This is similar to a pyramid scheme in that both are based on using new investors’ funds to pay the earlier backers. Both Ponzi schemes and pyramid schemes eventually bottom out when the flood of new investors dries up and there isn’t enough money to go around. At that point, the schemes unravel.” — Investopedia

Why Smart Contracts

Smart Contracts enable a perfect breeding ground for a new wave of fraudsters. Where traditional financial scammers have the law, 3rd party institutions and their public image to worry about, smart contracts don’t have the same issue:

  • Schemes can be deployed by any Ethereum address, ensuring (almost) complete anonymity.
  • No central authority can shut the smart contract down.
  • Due to the immutability of smart contracts, investors may develop a false sense of trust.

Pyramid Ponzi

The pyramid Ponzi scheme is exactly what you’d expect: one owner at the top with, let’s say, 5 investors below him. Each investor is incentivised to get 5 more investors below them, and so on and so on.

The investors at the top of the pyramid make money by bringing in new investors to pay back their original investment, and then some. Every time a new layer is added, everyone already in the pyramid makes loads of money.

Simple Chain Ponzi

A Chain Ponzi is a simpler version of the pyramid. Instead of multiple investors below each investor, they only have one. It’s one big chain.

In this example, I’m going to set up a scheme which “GUARANTEES TO DOUBLE YOUR MONEY” (until it can’t).

Here’s how it works.

Double your money

As the owner, I deploy a contract that allows anyone to join my DOUBLE YOUR MONEY GUARANTEED scheme. All I take is a small fee for every time someone invests, let’s say 10%.

Here’s a step by step:

  1. Alice invests 1ETH.
  2. I take 0.1ETH as my owner’s fee, the pot stands at 0.9ETH.
  3. Bob Decides to invest 1ETH also.
  4. I take my fee, and the pot now stands at 1.8ETH. No one has doubled their money yet, but I’ve made 0.2ETH for doing nothing.
  5. Charlie comes in with another 1ETH, this is where it gets interesting. I take my fee, and now the pot stands at 2.7ETH, enough to double Alice’s original investment.
  6. Alice gets paid 2ETH, doubling her money, she cuts and runs. The pot stands at 0.7ETH.
  7. Alice can’t believe that it worked, so she brings in her friend Dave who thinks hell yeah I’m doubling my money! Invests 3TH.
  8. I take my fee, the pot now at 4.4ETH, both Bob and Charlie get paid their winnings and the pot stands at 0.4ETH.
  9. And so on, and so on.

Code

The full project for this code can be found here

pragma solidity ^0.5.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
contract Doubler {
using SafeMath for uint;
address payable public owner;
struct User {
address payable addr;
uint amount;
}
User[] public users;
uint public currentlyPaying = 0;
uint public totalUsers = 0;
constructor() public {
owner = msg.sender;
}
function join() external payable{
users.push(User(msg.sender, msg.value));
totalUsers += 1;
owner.transfer(msg.value.div(10));
while (address(this).balance > users[currentlyPaying].amount.mul(2)) {
            users[currentlyPaying].addr.transfer(users[currentlyPaying].amount.mul(2));
currentlyPaying += 1;
}
}
}

As you can see, this is a super easy contract to make.

Every time a new investor joins the party, the join() function is called and performs the following:

  • Adds the new user to the list of investors with the amount they invested.
  • Transfers 10% to the owner.
  • Pay as many of the early investors as possible using what’s in the pot.

Conclusion

DeFi is the word on everyone’s lips at the moment, and it’s easy to get caught up in the excitement. New protocols and products are popping up every few hours.

Fortunately for the more nefarious amongst us, times like these signal ripe opportunity to make a quick buck out of the less informed. This has famously happened in the past in the crypto sphere (if you don’t know what I’m talking about, google “Carlos Matos”).

My prediction is that we will see a lot more “controversial” news about scams that ride on the coattails of the DeFi movement. Keep your wits about you, as they prey on our emotions and draw you in.

If you liked this, read the next instalment on Tree Shaped Ponzi Schemes on the Ethereum Network.

This article was inspired by a paper entitled “Dissecting Ponzi schemes on Ethereum: identification, analysis, and impact” by Massimo Bartoletti, Salvatore Carta, Tiziana Cimoli, Roberto Saia.

Learn More

If you enjoyed this post and want to learn more about Smart Contract security, Blockchain Development or the Blockchain Space in general, I highly recommend signing up to the Blockgeeks platform. They have courses on a wide range of topics in the industry, from Coding to Marketing to Trading. It has proven to be an invaluable tool for my development in the Blockchain space.

Ethereum
Solidity
Smart Contracts
Ponzi Scheme
Pyramid Schemes
Recommended from ReadMedium