https://github.com/austintgriffith/fruit-market-land
https://github.com/austintgriffith/fruit-market-land
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/austintgriffith/fruit-market-land
- Owner: austintgriffith
- License: mit
- Created: 2023-11-01T22:25:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-02T02:33:11.000Z (over 2 years ago)
- Last Synced: 2024-10-29T03:40:37.482Z (over 1 year ago)
- Language: TypeScript
- Size: 45.9 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# ๐ Fruit Market Land
๐งช this is forked from the fruit market repo [here](https://github.com/BuidlGuidl/fruit-market)
๐ต Buy Land and Grow Strawberries!

๐ฑ very ugly buttons for each land tile:

๐บ check out the land contract in `packages/hardhat/contracts/Land.sol`
```bash
git clone https://github.com/BuidlGuidl/fruit-market-land
cd /fruit-market-land
yarn install
```
> โ๏ธ bring up the chain and deploy your contracts
```bash
yarn chain
yarn deploy
yarn start
```
> ๐จ copy `packages/nextjs/.env.example` to the name `.env` and edit your frontend env:
> ๐ฟ you'll need to spin up a KV (key value storage) in vercel and copy/paste in the env.local fields:
```
NEXT_PUBLIC_DEPLOY_BLOCK=0
NEXT_PUBLIC_LIVE_URL=https://event-wallet.vercel.app
KV_URL=
KV_REST_API_URL=
KV_REST_API_TOKEN=
KV_REST_API_READ_ONLY_TOKEN=
```
> ๐ฑ hit the frontend at `http://localhost:3000`
> ๐ next, inspect the `targetNetwork` var in `packages/nextjs/scaffold.config.ts`
(if you are deploying locally it needs to be `chains.hardhat` or `chains.gnosis` out in prod)
> ๐โโ๏ธ login as with your nickname:

> ๐ท now you can use the browser to navigate to the `/checkedIn` route to drop tokens and gas to players:

โ ๏ธ your frontend address will need to be an admin to drop tokens to players
> ๐ edit `packages/hardhat/deploy/00_deploy_your_contract.ts` and add your address to `dexPausers`
> โ๏ธ redeploy the whole stack with `yarn deploy --reset`
๐ค try visiting [http://localhost:3000](http://localhost:3000) from an incognito window or another browser to have a fresh burner to play with
(check in with a burner and drop some funds to it using your other account and the `/checkedIn` page)
โ๏ธ at this point, player should be able to trade credits for resources on the dexes:

---
## Charts and Leaderboard
If you want to keep the charts and leaderboard updated you have to run a cron job requesting /api/admin/track-prices:
```
* * * * * /usr/bin/curl https://domain/api/admin/track-prices >> prices.log
```
Or you can set the cron job at Vercel using the /packages/nextjs/vercel.json config file.
(On localhost you can just use the browser to hit `http://localhost:3000/api/admin/track-prices` manually)
---
## Trading Bots
If you want prices to randomly fluctuate you need to run bots that have a bunch of liquidity and trade randomly:
```bash
git clone https://github.com/BuidlGuidl/fruit-market-trader
cd fruit-market-trader
yarn install
```
> ๐พ you will need to copy your `fruit-market` `packages/nextjs/generated/deployedContracts.ts` into this `fruit-market-trader/deployedContracts.js`
โ ๏ธ notice it changes from `.ts` to `.js` - you will also have to remove the `as const` from the end
(this tells your bots about the new contracts you've deployed)
โข๏ธ Notice: any time you need to redeploy, do `yarn deploy --reset` and recopy over your `deployedContracts.js`
> โ๏ธ copy the `.env.example` to `.env` file in the `fruit-market-trader` dir with the following info filled in:
```
DEPLOYER_PRIVATE_KEY=0xYOUR_PRIVATE_KEY_FROM_YOUR_LOCAL_STORAGE
GNOSIS_RPC=http://127.0.0.1:8545
GNOSIS_NETWORK_ID=31337
```
(you can get this private key from the local storage. it's called `scaffoldEth2.burnerWallet.sk`)
โฝ๏ธ if your this address is loaded up with local funds, you should be good to run:
```bash
node batchPrep.js
```
โ๏ธ this is going to generate a bunch of trader accounts, send them tokens, and save the private keys up in your `.env` file:

(if anything fails here it probably means your burner is not correctly funded with credits and assets and you can debug balances using http://localhost:3000/debug)
> ๐ now you can start a trading bot for each resource like:
```bash
node tradeDex.js Apple
```