austintgriffith / land-game-deploy-test

Repository from Github https://github.comaustintgriffith/land-game-deploy-testRepository from Github https://github.comaustintgriffith/land-game-deploy-test

πŸ“ Fruit Market Land

πŸ§ͺ this is forked from the fruit market repo here

πŸ’΅ Buy Land and Grow Strawberries!

image

πŸ“± very ugly buttons for each land tile:

image

πŸ—Ί check out the land contract in packages/hardhat/contracts/Land.sol

git clone https://github.com/BuidlGuidl/fruit-market-land

cd /fruit-market-land

yarn install

βš™οΈ bring up the chain and deploy your contracts

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:

image

🏷 now you can use the browser to navigate to the /checkedIn route to drop tokens and gas to players:

image

⚠️ 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 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:

image


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:

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:

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:

image

(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:

node tradeDex.js Apple

About

License:MIT License


Languages

Language:TypeScript 89.6%Language:Solidity 6.7%Language:JavaScript 3.5%Language:CSS 0.2%Language:Shell 0.0%