Git Product home page Git Product logo

example-dapp-game's Introduction

Demo DApp

Check out our running example here

Screenshot

Create your credentials

You'll need an app id to actually run this demo. Visit https://developer.bitski.com/ and click "Create App". You can enter anything for the name and leave the url blank for now.

Once your app is created, view your app details, then go to the OAuth settings, and under Redirect Urls, add the following:

http://localhost:3000/callback.html

At this point, your Bitski app should be ready to go. Create a .env file in the root of this project, then copy the app id from the app details page, and paste it like this:

BITSKI_CLIENT_ID=YOUR-APP-ID

Running Locally

Now you should be ready to run the demo app locally. First, install the dependencies.

npm install

Next, you'll need to use Truffle to deploy the contract. We'll start by running the contract on a local blockchain. Start by installing truffle globally.

npm install -g truffle

Then, start truffle's development blockchain

truffle develop

Once the development blockchain is running, then run the migrations in the dev console:

truffle(develop)> migrate

You can learn more about deploying contracts with truffle here.

Once the contracts are deployed, you can start the development server. Make sure to run the dev server in another terminal.

npm run dev

Then browse to http://localhost:3000 to interact with the app.

Deploying to a real network

Once you have your dapp how you want it, you'll want to deploy it to a live blockchain somewhere. This can be achieved using a local Ethereum node, or with Bitski's app wallet feature.

To use Bitski to deploy your contract, you'll need to create an App Wallet. Visit the developer portal, find your app in the list, and click it to view the details.

Under the Wallets tab, click New Wallet. Then, visit the Backend Credentials tab and click New Credential. You'll want to copy and paste both the credential id, and secret into your .env file like this:

BITSKI_CLIENT_ID=YOUR-CLIENT-ID
BITSKI_CREDENTIAL_ID=YOUR-CREDENTIAL-ID
BITSKI_CREDENTIAL_SECRET=YOUR-CREDENTIAL-SECRET

At this point, you should be ready to deploy your contracts.

Note: Make sure you have some ETH in your new app wallet before you try to migrate. The exact amount of ETH you will need depends on the contract.

To migrate your contract, decide which network you want to use, then run:

Mainnet:

truffle migrate

Kovan:

truffle migrate --network kovan

Rinkeby:

truffle migrate --network rinkeby

Once you've deployed your contract, update your bitski.config.js to reflect your network choice. Edit the network name under environments. This will make sure the web app will know what network to look for.

Note: You can configure networks for both development and production separately. You have the option to use a local test network for development, or once the contract is deployed, you can also develop against a real network. npm run dev will use the development options, and npm run build will use the production options.

Deploying the web assets

If you want to host your version of this dapp somewhere publicly, make sure to add the proper redirect url to both your bitski.config.js and your app on the Bitski Developer Portal. You won't be able to log in unless the redirect url passed in exactly matches what is listed in your app's settings.

To build the app for production, simply run:

npm run build

The app will be compiled into the ./dist directory. You should be able to simply drop these assets on any standard web server to host.

Token Metadata

ERC721 tokens support various metadata by providing a URL for the token that includes structured information in json. This is stored on the blockchain when each token is minted. Update the tokenURIBaseURL value in webpack.config.js to provide a valid url if you would like to use this functionality.

Modifying the Smart Contract

The backend of our dapp is a contract on Ethereum. The code of this contract is located in contracts.

Game

The front end of our app is a game using the Phaser framework. The code is located in app and the assets are located in assets.

example-dapp-game's People

Contributors

pixelmatrix avatar ptescher avatar jtescher avatar

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.