Giter Site home page Giter Site logo

sarvex / break Goto Github PK

View Code? Open in Web Editor NEW

This project forked from solana-labs/break

0.0 1.0 0.0 24.51 MB

Break Solana Game

Home Page: https://break.solana.com

License: MIT License

Shell 0.06% JavaScript 0.31% Rust 0.98% TypeScript 62.02% CSS 4.13% HTML 0.63% SCSS 31.87% Procfile 0.01%

break's Introduction

Break Solana Game Build Status

How it works

The Break Solana Game consists of a 3 parts: a web client frontend, a web server backend, and an on-chain Solana program. The web server backend is not strictly required but it helps with certain performance improvements.

At a basic level, the Break Solana Game allows a player to send simple smart contract transactions as fast as they can to showcase Solana's speed. The web frontend is responsible for creating, sending, and confirming transactions and displays the status of each transaction in a colored grid. The web backend helps out by acting as a fast relay for transactions. It will forward transactions directly to the TPU (transaction processing unit) UDP port of the current cluster leader node (typically transactions are first sent to an RPC API node for forwarding). It also helps by creating a supply of game accounts ahead of time to speed up game setup time (these accounts can be tracked across server restarts using Redis).

Rather than subscribing to each transaction signature, the web client subscribes to account data updates. Each transaction will set a bit in the state within a Break program account, so each transaction can be uniquely identified by the bit it sets.

Prerequisites

Solana CLI Tooling: https://docs.solana.com/cli/install-solana-cli-tools For running this application you need to have NodeJs and NPM. We recommend to use NVM for managing NodeJs versions For NVM installation please refer to manual

Install

npm install

Run Server

Note: If the cluster you connect to doesn't provide a faucet, you will need to supply the server with a payer key. (See 'Configuration' below).

# Start local node
solana-test-validator

# Deploy program to local node
cd program
cargo build-bpf
solana program deploy target/deploy/break_solana_program.so --url localhost

# Connect to local node
cd server
npm run start:dev

Configuration

By default, the Break server will connect to a local node for RPC. To configure this behavior, set the following environment variables when running the server:

PORT

Set this option to specify the port for the API server. Default is 8080.

PORT=80 npm run start:dev
RPC_URL

Set this option to connect to a specific remote RPC API server.

RPC_URL=http://api.mainnet-beta.solana.com npm run start:dev
LIVE

Enable this option to connect to a remote cluster. The default cluster is devnet.

LIVE=true npm run start:dev
CLUSTER

Enable this option along with LIVE=true to connect to a specific remote cluster.

LIVE=true CLUSTER=devnet npm run start:dev
LIVE=true CLUSTER=testnet npm run start:dev
LIVE=true CLUSTER=mainnet-beta npm run start:dev
DEPLOYED_PROGRAM_ADDRESS

Set this option to use an existing loaded Break Solana program rather than load a new version. If the program doesn't exist, the server will exit with an error.

DEPLOYED_PROGRAM_ADDRESS=<BASE58 ENCODED ADDRESS> npm run start:dev

To use the Break Solana program that's used on https://break.solana.com, use the following address:

DEPLOYED_PROGRAM_ADDRESS=BrEAK7zGZ6dM71zUDACDqJnekihmwF15noTddWTsknjC npm run start:dev
SEND_TO_RPC

Enable this option to send transactions to the RPC API rather than directly to a validator TPU port.

SEND_TO_RPC=true npm run start:dev

Run Client

cd client
npm run start

Configuration

Client behavior can be modified with the usage of url parameters.

cluster

Set this parameter to pick a remote cluster. This parameter is automatically set when using the UI cluster selector.

https://break.solana.com/game?cluster=devnet
commitment

Set this parameter to set the commitment level used for confirming transactions. Default is 'confirmed' but 'processed' is also supported.

https://break.solana.com/game?commitment=processed
debug

Set this parameter to enable "debug mode" which will display a table of confirmation times instead of the colored grid.

https://break.solana.com/game?debug
retry

Set this parameter to disable retrying transactions which have not yet been confirmed. Retry behavior is enabled by default because some transactions will be forwarded to a leader who skips their block slot.

https://break.solana.com/game?retry=disabled
split

Set this parameter to split transactions across multiple payer and program accounts to increase transaction parallelization. Default is 4.

https://break.solana.com/game?split=1
test

Set this parameter to enable "test mode" which will automatically send approximately 33 transactions per second.

https://break.solana.com/game?test

Built With

break's People

Watchers

 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.