Giter Site home page Giter Site logo

ewrvp7lv7 / rust-counter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from frol/rust-counter

0.0 0.0 0.0 843 KB

Simple counter in Rust. Increment, decrement, and reset. See branches for extended usage.

License: MIT License

JavaScript 33.50% Rust 21.25% TypeScript 9.25% CSS 24.90% HTML 11.09%

rust-counter's Introduction

Counter example in Rust

Open in Gitpod!

Description

This contract implements simple counter backed by storage on blockchain. Contract in contract/src/lib.rs provides methods to increment / decrement counter and get it's current value or reset.

Plus and minus buttons increase and decrease value correspondingly. When button L is toggled, a little light turns on, just for fun. RS button is for reset. LE and RE buttons to let the robot wink at you.

To Run

Open in the Gitpod link above or clone the repository.

git clone https://github.com/near-examples/rust-counter

Install dependencies:

yarn

If you don't have Rust installed, complete the following 3 steps:

  1. Install Rustup by running:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

(Taken from official installation guide)

  1. Configure your current shell by running:
source $HOME/.cargo/env
  1. Add wasm target to your toolchain by running:
rustup target add wasm32-unknown-unknown

Next, make sure you have near-cli by running:

near --version

If you need to install near-cli:

npm install near-cli -g

Login

If you do not have a NEAR account, please create one with NEAR Wallet.

In the project root, login with near-cli by following the instructions after this command:

near login

Modify the top of src/config.js, changing the CONTRACT_NAME to be the NEAR account that was just used to log in.


const CONTRACT_NAME = 'YOUR_ACCOUNT_NAME_HERE'; /* TODO: fill this in! */

Start the example!

yarn start

To Test

yarn test

To Explore

  • contract/src/lib.rs for the contract code
  • src/index.html for the front-end HTML
  • src/main.js for the JavaScript front-end code and how to integrate contracts
  • src/test.js for the JS tests for the contract

To Build the Documentation

cd contract
cargo doc --no-deps --open

rust-counter's People

Contributors

mikedotexe avatar dependabot-preview[bot] avatar gagdiez avatar thisisjoshford avatar idea404 avatar janedegtiareva avatar dependabot[bot] avatar chadoh avatar mehtaphysical avatar user942blib avatar vgrichina avatar doriancrutcher avatar volovyks avatar frol avatar tarasenkofirelabs 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.