Coder Social home page Coder Social logo

projectsophon / df-play-to-earn Goto Github PK

View Code? Open in Web Editor NEW
26.0 4.0 7.0 2.42 MB

Dark Forest plugins to earn xDai while playing the game.

Home Page: https://play2earn.projectsophon.com/

License: GNU General Public License v3.0

Solidity 6.93% TypeScript 80.10% JavaScript 0.10% CSS 7.67% HTML 5.20%

df-play-to-earn's Introduction

df-play-to-earn

Dark Forest plugins to earn xDai while playing the game.

Getting the plugin

The plugin is bundled during the website deploy and published at https://play2earn.projectsophon.com/BroadcastMarketPlugin.js

You can use the plugin from our website by creating a new plugin with the contents:

export { default } from "https://play2earn.projectsophon.com/BroadcastMarketPlugin.js";

Developing plugins with interop contracts

Requirements: Node.js 14+ & Yarn

To develop on this project, or build your own plugins that have interop contracts, you can clone this repo with:

git clone --recurse-submodules git://github.com/projectsophon/df-play-to-earn

That command will clone the project and the projectsophon/hardhat-network-fork submodule.

The submodule contains a cache of the Dark Forest v0.6 Round 1 contract on the xDai network at block 16240564. The cache is pre-seeded from the 0xa9fcdf168759fbe712a651323b2f98d9ae141215 address, so your mileage may vary with loading the cache.

If you need to refetch or update the cache submodule (such as after cleaning the project), you can run the command:

git submodule update --init --recursive

Once you've cloned the project, you need to get all the dependencies. In the project directory you'll need to run:

yarn

If you started playing after blockNumber in hardhat.config.ts you'll need to update it to a block after your wallet address was whitelisted in the production game, or the game will keep asking you for a whitelist key.

Note: You probably want to edit the hardhat.config.ts to include your own player. See Setting up a new user for details.

Once that is done, you'll need to run our local node with a fork of xDai, so run:

yarn start

This does a bunch of stuff! It forks xDai mainnet at our given block number, fast-forwards the chain time to right now, deploys our contracts into the local testnet, drips players some fake xDai, starts mining blocks every 5 seconds, and launches a development server for our plugin code to be served from. Whew!

Once the local testnet is up-and-running, you'll need to clone a copy of the Dark Forest game client using:

git clone git://github.com/darkforest-eth/client

Inside that repository, you'll also need to run:

yarn

And, once that is done, start the client with:

yarn start:dev

This will start the game client that connects to our local test net running on http://localhost:8545 but using the actual production contract addresses that we forked from xDai mainnet!

Once the game launches, you'll log in like normal, importing your private key from your primary account. The first load will probably take 10s of minutes ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ depending on the xDai RPC node you are forking from but the blocks are cached after that.

Upon finally logging into the game, you'll be able to create a new plugin containing:

export { default } from "http://localhost:2222/BroadcastMarketPlugin.js";

Setting up a new user

If you want to be dripped some counterfeit xDai, add your wallet address as new player object to env.players inside hardhat.config.ts. You'll can add another object like this:

{
  address: "YOUR_ADDRESS_HERE",
  forkFund: "100",
}

Deploying production contracts

Create a .env file with your deployer mnemonic like:

DEPLOYER_MNEMONIC=dog dog dog dog dog dog dog dog dog dog dog cat

Adjust contract settings to taste in extendEnvironment of hardhat.config.ts

Finally run:

npx hardhat deploy --network xdai

License

GPL-3.0

df-play-to-earn's People

Contributors

jacobrosenthal avatar phated avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

df-play-to-earn's Issues

Request list isn't updated as you mine the universe

You need to change tabs or close-reopen. It'd be cool if it would re-render the list with new planets you found while exploring.

Might be able to hook up the "discovered new chunk" event in the future.

RevealRequested and RevealCollected could probably just have location argument

Currently, I can construct a fake "raw" response from the contract using the arguments from RevealRequested but I don't think it'd be that bad to just fetch the struct if I see one (unsure?); however, RevealCollected really just needs the location to filter it out of my list (I may just start tracking all collected in another list to toggle them).

Gas Price?

We are using the default (which is probably 1 gwei?) but that might not work on current xdai.

Bugs with the input box

I can type a huge number greater than my wallet amount which screws up all the calculations even though it resets the value in the box. I might need to do an extra calculation or maybe just uncap it and let it fail if they try to post something bigger than wallet amount

Need `getAllRevealRequests` function

Don't really need bulkGetRevealRequests because I don't want to make another call to get the array length (plus it might increase in that round trip?).

I implemented locally with bulkGetRevealRequests so could keep it around but private.

Cant see my broadcast requests: Cannot read property 'subscribe' of undefined

Uncaught (in promise) TypeError: Cannot read property 'subscribe' of undefined
    at subscribeToMyBalance (BroadcastMarketPlugin.js:6707)
    at Object.__ (BroadcastMarketPlugin.js:6993)
    at j2 (BroadcastMarketPlugin.js:5521)
    at Array.forEach (<anonymous>)
    at l.__r (BroadcastMarketPlugin.js:5482)
    at j (BroadcastMarketPlugin.js:5337)
    at w (BroadcastMarketPlugin.js:5242)
    at L (BroadcastMarketPlugin.js:5381)
    at j (BroadcastMarketPlugin.js:5339)
    at w (BroadcastMarketPlugin.js:5242)

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.