Giter Club home page Giter Club logo

massa-sc-template's Introduction

Hello world ๐ŸŒ

Hello world project for Massa's smart contracts development. This preset environment can be used to test and debug locally your smart contract before sending it to the Massa network.

Quick setup ๐Ÿงฐ

You need node, npm and npx to initialize the project!

npx massa-sc-create hello-world

N.B. if you didn't initialize this project with npx, you can clone and customize manually this repository with the command below. You'll be able to change the version of massa-sc-std if it's not already at the latest version.

git clone https://github.com/massalabs/massa-sc-template

Once this repository is cloned, run the following command in the freshly created directory:

npm install

Usage โœ๏ธ

You can run scripts described in the package.json with yarn run {script_name}, if you're not confident with the package.json, take a minute to look at the yarn documentation.

I'll describe the different embedded scripts in this section and redirect to several documentations if required.

  • build: generate a .wasm file in a build/ directory for src/smart-contract.ts and src/main.ts. This is the hello world smart contract example. If you look at this command line, you can see that we use the asc binary, this is the AssemblyScript compiler. Here is the documentation if you want to know more. The build/smart-contract.wasm is a simple smart-contract that can be sent to the blockchain and will be executed once and then drop. The build/main.wasm will store this hello world on the blockchain and so you will be able to call it whenever you want.
  • clean: remove build artifacts and temporary ledger file.
  • test: (not yet implemented) execute the smart contract on a mock with the massa-sc-test binary. Look at the mock repository here for more information about mocking the network.
  • publish: (not yet implemented) publish bin/main.wasm smart contract to a given Massa network node.

Mocked ledger ๐Ÿ‘›

To test your smart contracts locally, download the massa-sc-tester release that corresponds to your environment. Unzip the downloaded file and put the executable in ./bin directory. Make sure that the right access permissions are set with chmod.

Once you ran the exec script, you should see a new file in the directory named ledger.json. This file represents the local state of the ledger for your test. You can modify it manually (obviously, carefully) to look at the state of the ledger after each execution.

For now, the execution on the mocked ledger doesn't behave exactly like on the real massa network, in particular if the execution of a smart-contract fails. The ledger file is modified each time you run a code that writes on the ledger file and there is no backup management. It means that even if your code failed after writing in the ledger, the modifications are saved while the execution would be reverted on the real massa network.

Report an issue ๐Ÿšฉ

If you get an issue with massa-sc-test we would appreciate a report on the dedicated repository. Use an appropriate language and explain step by step your problem with examples and screenshots.

massa-sc-template's People

Contributors

yvan-sraka avatar adrien-zinger avatar qdrn avatar nirnaeth-arnoediad avatar aurelienft avatar damip 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.