/p-00-near

Simple Contracts NEAR, keeping track of Scores Leaderboard

Primary LanguageTypeScript

near-sdk-as NFL Fantasy Between Friends

This is a learning excersie to explore NEAR. The idea: Every year a group of friends play a simple version of NFL Fantasy. The goal of this project is mange both the pool and the weekly scores of the game. To do this, we will have to create two contracts. One contract will hold the funds of the pool and the other contract will keep track of the scores.

Rules and Process

  1. A player should add $NEAR in a pool to be able to play.
  2. From a preselected table of 6 columns and each row containing NFL teams, you select one Team from each column.
const GAME_LINE_UP = {
  year: "2021",
  block_1: ["KC", "BUF", "GB", "PIT"],
  block_2: ["TB", "SEA", "NO", "BAL"],
  block_3: ["TEN", "CLE", "IND", "MIA", "LA", "OAK"],
  block_4: ["ARI", "CHI", "NE", "SD", "WAS", "MIN"],
  block_5: ["NYG", "DAL", "SF", "DEN", "DET", "CAR"],
  block_6: ["CIN", "PHI", "HOU", "ATL", "NYJ", "JAX"],
};
  1. If your team wins a game, a plus 1 gets added to your wins.
  2. If your team loses, your wins stay the same.
  3. We also track how many points the team score (for tie breaker).
  4. After regular season is over, the player with the most points picks first a team they want to take to the superbowl.
  5. Teams get assigned until there are no teams left. If a player does not get a team, this is the end the road for that player.
  6. Prices are then divided 50%(1st), 30%(2nd), 20%(3rd).

Contracts

  • Scores in the src/Scores folder

Getting started

  1. clone this repo to a local folder
  2. run yarn
  3. run ./scripts/1.dev-deploy.sh
  4. run ./scripts/2.use-contract.sh (uncomment/modify line 51 (where we call addPlayerToScore on the contract))
  5. run ./scripts/2.use-contract.sh (yes, run it again, but first change the score you want to add first)
  6. run ./scripts/3.cleanup.sh

The file system

├── README.md
├── as-pect.config.js
├── asconfig.json
├── package.json
├── scripts
│   ├── 1.dev-deploy.sh
│   ├── 2.use-contract.sh
│   ├── 3.cleanup.sh
│   └── README.md
├── src
│   ├── as_types.d.ts
│   ├── Scores
│   │   ├── __tests__
│   │   │   ├── as-pect.d.ts
│   │   │   └── index.unit.spec.ts
│   │   ├── asconfig.json
│   │   └── assembly
│   │       └── index.ts
│   ├── tsconfig.json
│   └── utils.ts
└── yarn.lock