• Stars
    star
    269
  • Rank 152,662 (Top 4 %)
  • Language
    Solidity
  • License
    GNU Affero Genera...
  • Created about 3 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NFT distribution with (1) randomized, multi-winner raffles and (2) bulk on-chain metadata generation.

MultiRaffle

About | Implementation | License

About

MultiRaffle is an unaudited, unoptimized NFT distribution reference, implenting a randomized multi-winner raffle and randomized on-chain metadata generation.

It allows operators to quickly deploy an NFT distribution that allows users to purchase refundable raffle tickets, potentially win NFTs, and randomly assign metadata to these NFTs via Chainlink VRF.

Implementation

  1. Each raffle begins with an operator assigning constants including NFT Name, NFT Symbol, Mint Cost (per NFT), Raffle Start Time, Raffle End Time, Available NFT Supply, and Max Raffle Entries per Address.
  2. Then, for the period that the raffle is active, users can enter the raffle and claim up to Max Raffle Entries per Address tickets.
  3. Once the raffling period is finished, the NFTs can be distributed among winning tickets. If there are fewer purchased tickets than the Available NFT Supply, no clearing is required. Else, anyone can and must call clearRaffle (either in partial steps socializing gas cost, or all at once) to forward Fisher-Yates shuffle the raffle entries and choose winners.
// Fisher-Yates shuffle across set of raffle tickets
for (uint256 i = shuffledCount; i < shuffledCount + numShuffles; i++) {
    // Generate a random index to select from
    uint256 randomIndex = i + entropy % (raffleEntries.length - i);
    // Collect the value at that random index
    address randomTmp = raffleEntries[randomIndex];
    // Update the value at the random index to the current value
    raffleEntries[randomIndex] = raffleEntries[i];
    // Update the current value to the value at the random index
    raffleEntries[i] = randomTmp;
}
  1. Once winning tickets have been determined, users can claim either NFTs for their winning tickets or a refund for their losing tickets.
  2. Finally, once users have their NFTs, they can choose to reveal metadata. This will randomly reveal the metadata for all NFTs pending metadata.
// Metadata for range of tokenIds (batch applied to startIndex - endIndex)
struct Metadata {
    // Starting index (inclusive)
    uint256 startIndex;
    // Ending index (exclusive)
    uint256 endIndex;
    // Randomness for range of tokens
    uint256 entropy;
}

Build and Test

# Collect repo
git clone https://github.com/anish-agnihotri/MultiRaffle
cd MultiRaffle

# Checkout tests branch to modify contract to mock Chainlink
git checkout -t origin/tests

# Run tests
make
make test

Installing the toolkit

If you do not have DappTools already installed, you'll need to run the commands below:

Install Nix

# User must be in sudoers
curl -L https://nixos.org/nix/install | sh

# Run this or login again to use Nix
. "$HOME/.nix-profile/etc/profile.d/nix.sh"

Install DappTools

curl https://dapp.tools/install | sh

License

GNU Affero GPL v3.0

Credits

  • @gakonst/lootloose for DappTools info + inspiration
  • ds-test, OZ, Chainlink for inherited libraries

Disclaimer

These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. Paradigm is not liable for any of the foregoing. Users should proceed with caution and use at their own risk.

More Repositories

1

merkle-airdrop-starter

Frontend, contracts, and merkle tree generator for use in quickly scaffolding ERC20 token airdrops.
TypeScript
702
star
2

flashside

Long-tail MEV contracts to claim Otherside land NFTs
Solidity
567
star
3

pool-sniper

Uniswap V2-styled router new pool sniping in under 250 LOC.
TypeScript
434
star
4

punk-nftx-meebit-arb

Quick & dirty NFTX arbitrage contracts, via flash loan, to exploit Meebit redemption.
Solidity
246
star
5

goblinmode

Long-tail NFT MEV via NFTX flashloans (McGoblinBurger NFTs)
Solidity
237
star
6

dhof-loot

Scripts to collect statistics about Loot + derivative projects.
JavaScript
228
star
7

MultiFaucet

MultiFaucet drips ETH, tokens, and NFTs across many testnet networks, at once.
TypeScript
166
star
8

tweetdrop

Generate dispersable airdrops from Twitter threads.
TypeScript
150
star
9

mevboost.org

Aggregates statistics about mev-boost relays and block builders
TypeScript
147
star
10

Hyperbitcoinization

$1 Million USDC vs 1 Wrapped Bitcoin 90-day term bet, inspired by Balaji's tweet
Solidity
119
star
11

partybid

PartyBid is a collector DAO that lets individuals pool capital, bid on Mirror's reserve auctions, and resell NFTs.
Solidity
119
star
12

GateRepo

Token-gated repositories via GitHub API.
TypeScript
116
star
13

quadratic-voting

Real-time Quadratic Voting dashboard to encourage mathematically optimal voting in democratic communities.
JavaScript
93
star
14

sushiswap-exploit

SushiSwap RouteProcessor2 exploit repro + supporting data useful for whitehats.
Solidity
84
star
15

flipper

Scrape ERC721 metadata, flip images, test creative permissiveness.
TypeScript
80
star
16

pawnft

NFT-collateralized lending primitive, via active auctions.
TypeScript
78
star
17

blog-effective-nft-launches-data

Data+code for NFT launch guide blogpost.
Jupyter Notebook
70
star
18

weve

A Weavemail client implementation—private, decentralized and open source mail, built on Arweave.
JavaScript
65
star
19

quadratic-funding

Quadratic Funding is the mathematically optimal way to fund public goods in a democratic community.
JavaScript
54
star
20

zora.gallery

Open protocols demand open access. Community-operated interface to the Zora Protocol.
JavaScript
51
star
21

waffle

NFT raffles via Chainlink VRF.
Solidity
46
star
22

lootloose.com

LootLoose lets you unbundle your Loot Bags into individual item NFTs or rebundle items into their original Loot Bags.
TypeScript
34
star
23

flashbots-connect-rpc

Website to enable users to add the Flashbots Protect RPC endpoint to MetaMask.
TypeScript
28
star
24

Just-Law

Legal document search engine to provide new insight into document representation and retrieval. Built with Java, JavaScript, SMMRY API + NLP.
HTML
23
star
25

tubby-cats-data

Statistics from Tubby Cats NFT minting
JavaScript
22
star
26

stat.farm

Stat.Farm is a @compound-finance dashboard and COMP governance token distribution calculator.
JavaScript
21
star
27

daochess.org

daochess pits governance systems against each other in real-time games of Chess, testing mechanisms and coordination.
JavaScript
21
star
28

uniswap-lp-nfts

Solidity -> JavaScript translation of Uniswap's NFTSVG library.
JavaScript
20
star
29

ens-lootbox

Bounty/Lootbox system for incentivizing donations of celebrity ENS names.
JavaScript
20
star
30

algosearch

Algorand (ALGO) Blockchain Explorer and Analytics platform.
JavaScript
14
star
31

lootrng.com

Community-operated website for the Loot project.
TypeScript
13
star
32

wineft

It's like Wine, but as a fungible token, and it ages.
JavaScript
12
star
33

purse-app

Open-source blockchain explorer and automatic wallet tracker built with React Native.
JavaScript
11
star
34

Encrypton

Trusted document sharing on a trustless ledger. Using IPFS + Ethereum.
JavaScript
11
star
35

filstats.com

Explore Filecoin's storage market and analyze the cost of storing your files.
JavaScript
10
star
36

Memory

Enter, track, cherish. Look back at your best moments with Memory. iOS-first mood tracker & diary app built using React Native, React Navigation, and Realm. 📦 Available on the iOS App Store!
JavaScript
9
star
37

ukraine-donation-roots

Merkle root of Ukraine donators
8
star
38

yield-liquidator

TypeScript
6
star
39

SignRecord

Publicly verifiable document records and credentialization platform backed by a distributed blockchain, de-centralized IPFS host, and with an outbound REST API.
JavaScript
5
star
40

comp.vote

JavaScript
5
star
41

arbitrage-uniswap

JavaScript
3
star
42

anish-agnihotri.github.io

Personal portfolio website. Updated before changes are pushed to deployed version.
HTML
3
star
43

venti

The hip browser-only Ethereum IDE and runtime environment.
JavaScript
3
star
44

solidity_playground

Just a quick and easy playground to store some solidity code that I've been practicing.
JavaScript
2
star
45

touchCoin

touchCoin was a development of a blockchain focused around ease of use, and increased block-times. By developing two GUI clients, one Command line interface, and one Android application, and a website we made it as easy as possible for the average user to use our technologies.
C++
2
star
46

anishagnihotri.com

TypeScript
1
star
47

cryptoeconomics

1
star
48

Gitcoin-Exemplars

Easy to copy formatting exemplars for running effective Gitcoin bounties.
1
star
49

dancefest-redo

JavaScript
1
star
50

UEscrow

UEscrow is a platform built for the UCash ERC-20 token at BlockHackTO 2018. It was built as being a simple, dynamic solution to easy escrow for transactions and cross+off-chain exchanges.
JavaScript
1
star
51

golearn

Go
1
star
52

Portfolio

Creative Agency portfolio template developed in HTML, SASS, and Javascript. Free to use under the MIT license for anyone as long as credit is provided to Anish Agnihotri.
CSS
1
star
53

patreaion

Decentralized subscriptions platform built on Aion.
Vue
1
star
54

toronto-waste-wizard

Simple web app to search the Toronto Waste Wizard database. Developed as a part of my application to the Shopify Summer 2019 Internship program.
CSS
1
star