Git Product home page Git Product logo

near-checksum's Introduction

near-checksum

Implementation of a checksum any data on NEAR Protocol

Develop

make fix
make qa
make build
make clean

Run CI local

Installation act:

brew install act

Setup env vars:

echo "GITHUB_TOKEN=%GITHUB_TOKEN%" | tee .secrets

Run

act --help

Deploy stage

make deploy-force
accountId=ilyar.testnet
contractName=$(cat neardev/dev-account)
near state $contractName
near delete $contractName $accountId

Deploy testnet

make qa
make build
accountId=ilyar.testnet
contractName="checksum.$accountId"
near create-account --masterAccount $accountId $contractName 
near deploy --wasmFile build/checksum.wasm --accountId $contractName

Usage

near view $contractName has '{"hash": "c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2"}'
near call $contractName add '{"data": [102, 111, 111, 98, 97, 114]}' --accountId $accountId
near view $contractName has '{"hash": "c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2"}'

Note init

https://docs.near.org/docs/tutorials/contracts/intro-to-rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
mkdir near-checksum  && cd $_
git init
cargo init --edition 2018 --lib --vcs git

near-checksum's People

Contributors

ilyar avatar

Watchers

 avatar  avatar

near-checksum's Issues

Redundand hash data

You store redundant data.
You operate with hash as a String. But store as Vec<u8>

        let checksum = env::sha256(&data);
        ...
        if !self.hash_set.insert(&checksum) {
            env::panic(b"Failed to save checksum");
        }

You should store it as a String.

Change basic path for source file

Cargo.toml
remove:

path = "src/contract/main.rs"

you don't need to change default path src/main.rs.

Also your app is not executable.
So change src/main.rs -> src/lib.rs

Also change

version = "1.0.0-beta.0"

to

version = "0.1.0"

Also remove name from section:

[lib]
name = "checksum"

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.