![Glossy Mesh 2D Ponzi Pyramid Scheme](https://coingeek.com/wp-content/uploads/2022/03/smart-contract-based-pyramid-scheme-on-bitcoin-min.webp)
Getting your Trinity Audio player ready...
|
This post was first published on Medium.
According to Wikipedia:
a pyramid scheme is a business model that recruits members via a promise of payments or services for enrolling others into the scheme, rather than supplying investments or sale of products.
We develop a pyramid scheme based on a smart contract. To join, every participant has to pay a fee to interact with the contract. The contract guarantees the new participant a 100% return¹, as long as he can recruit two more participants. Since the whole pyramid scheme is automatically enforced by smart contract, it is transparent and trustless.
![Pyramid Transactions: numbers in red after / denote satoshis](https://coingeek.com/wp-content/uploads/2022/03/smart-contract-based-pyramid-scheme-on-bitcoin-2.webp)
In the example above, Alice has paid a entry fee of x, which entitles her to be the beneficiary in UTXO0. If she convinces Bob and Charlie to join, each paying x, she is guaranteed to be paid 2x, which in turn renews the scheme but with Bob and Charlie as the new beneficiaries. The scheme continues, as long as new investors can be found.
The full code is shown below.
// A transparent Pyramid scheme | |
contract Pyramid { | |
@state | |
PubKeyHash schemer; | |
// satoshi amount required to enter the scheme | |
int entryFee; | |
// dust limit | |
static const int DUST = 1; | |
// recruite two members to get double payout | |
public function recruit(PubKeyHash recruit0, PubKeyHash recruit1, SigHashPreimage txPreimage) { | |
// use ANYONECANPAY so recruits can deposit | |
SigHashType sigHashType = SigHash.ANYONECANPAY | SigHash.ALL | SigHash.FORKID; | |
require(Tx.checkPreimageSigHashType(txPreimage, sigHashType)); | |
// commission payout: double the original entry fee | |
bytes commissionScript = Utils.buildPublicKeyHashScript(this.schemer); | |
bytes commissionOutput = Utils.buildOutput(commissionScript, 2 * this.entryFee); | |
// keep the scheme going from recruit0 | |
this.schemer = recruit0; | |
bytes recruitScript0 = this.getStateScript(); | |
bytes recruitOutput0 = Utils.buildOutput(recruitScript0, DUST); | |
// keep the scheme going from recruit1 | |
this.schemer = recruit1; | |
bytes recruitScript1 = this.getStateScript(); | |
bytes recruitOutput1 = Utils.buildOutput(recruitScript1, DUST); | |
bytes output = commissionOutput + recruitOutput0 + recruitOutput1; | |
require(hash256(output) == SigHash.hashOutputs(txPreimage)); | |
} | |
} |
Line 15 use ANYONECANPAY so Bob and Charlie can add their inputs independently, each having x satoshis².
***
NOTES:
[1] This assumes dust limit is negligible. The first participant earns more than 100% since he only has to pay the transaction fee to deploy the contract.
[2] We ignore transaction fee, which can be easily covered by another input.
Watch: CoinGeek New York panel, BSV vs. Other Blockchains: Differences that Matter for Developers & Businesses