Git Product home page Git Product logo

simple_counter_as's Introduction

Simple Counter

This example shows how to make a simple NEAR AssemblyScript contract. Normally the sdk does a lot behind the scenes. When calling a function with arguments it deserializes it for you, so in this example each exposed function has no arguments. Furthermore, if a function returns a value the sdk will serialize it for you too, so again these functions do not return anything.

Unfortunately current the serialization must be imported, which adds bloat to the generated binary. In this example we only use the host imports and the generated optimized binary is only 309 bytes!

The advantage to using AssemblyScript is that you can write code that generates Wasm text that is readable and close to the code that you wrote. This makes AssemblyScript a great language to learn about WebAssembly!

Build it

Running yarn under folder or path of this project will auto download missing packages and init the build environment.

Then running yarn build will build both a debug and a release version of the binary and a text version.

See build/debug/simple_counter_as.wat and build/release/simple_counter_as.wat for the generated Wasm in text mode.

Running yarn test will run a simple unit test.

simple_counter_as's People

Contributors

abc-xx avatar

Watchers

James Cloos avatar

Forkers

jkeohan

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.