Coder Social home page Coder Social logo

0xkahi / non-fungible-football Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cartridge-gg/non-fungible-football

0.0 0.0 0.0 2.94 MB

An onchain Game of Football

Home Page: https://nff.gg

JavaScript 0.28% Python 0.87% TypeScript 8.44% CSS 0.01% Solidity 0.26% Cairo 90.15%

non-fungible-football's Introduction

Non Fungible Football

image

Non Fungible Football is an onchain game that will take place during the World Cup 2022 (22 Nov to 20 Dec).

It's an NFT based game, where players randomly draw a player at the beginning of the tournament and progress through the tournament with the player they currently own.

Rules

  1. 1 Player == 1 NFT.
  2. 32 national teams with 26 players each == 832 total players.
  3. Once a team is knocked out, all its players are knocked out.
  4. Holders of the championship teams players win the championship.

Implementation

Everything is stored onchain. Player NFT's, the tournament results, the tournament logic. We take advantage of Starknet computational abilities to resolve the tournament. Fixture results are commited by an oracle (soon to be a vote by players).

Onchain Rendering

Player images are fully rendered onchain. In order to do so, preprocessing of the image parts is done in images/parse.py. The script outputs a cairo library with lookup functions which return each part split into felt*.

For example:

func lookup_body(index: felt) -> (part_len: felt, part: felt*) {
    let (addr) = get_label_location(data_start);

    let mapping = alloc()
    
	mapping[0] = 0
	mapping[1] = 13376
	mapping[2] = 27011
	mapping[3] = 40544

    let value = cast(addr + index, felt*);
    return (part_len=value[0], part=value+1);

	data_start:
	// body/skin_04.png 13375 0
	dw 13375;
	dw '<rect fill="rgb(112,71,47)" he';
	dw 'ight="1" width="1" x="31px" y=';
	dw '"17px" /><rect fill="rgb(112,7';
    ...
}

Oracle

Currently the tournament relies on an oracle for game outcomes. In the future, we would like to gamify this aspect. The mechanism would work as follows:

  1. One of the teams participating in a match can propose an outcome (score).
  2. All teams not participating can vote y/n to confirm the score.
  3. If the score is overturned, the proposers NFT is burned.
  4. Participants are rewarded for proposals / votes inline with the confirmed outcome with a portion of the pot.

Bracket resolution

Once the group stage has been finalized, the knockout bracket is seeded. The tournament contract computes the outcome of the tournament onchain, based on each individual game outcome (i.e. implements the official tournament rules).

Minting

Players will be revealed after the mint is complete, so you can't pick a player or team.

The winners will receive a trophy, which unlocks the final prize.

Development

Testing

protostar test tests

Deployment

cd contracts
protostar build
protostar declare ./build/proxy.json --network=testnet
Class Hash: `0x01067c8f4aa8f7d6380cc1b633551e2a516d69ad3de08af1b3d82e111b4feda4`

protostar declare ./build/player.json --network=testnet
Class Hash: `0x05430d4e450a6263fa15e310358e2ce8b255ea85c538157a5feecb776ccb2ef9`

Proxy Class Hash: 0x01067c8f4aa8f7d6380cc1b633551e2a516d69ad3de08af1b3d82e111b4feda4

Player Class Hash: 0x05430d4e450a6263fa15e310358e2ce8b255ea85c538157a5feecb776ccb2ef9

Credits

Mr Fax (art) Click_save / Sobriquet (design) Broody (web) Tarrence (contracts)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.