Giter Club home page Giter Club logo

koinos-as-sdk-examples's Introduction

Test Ubuntu Test Windows Test MacOS

Koinos AssemblyScript SDK Examples

DISCLAIMER: NONE OF THESE CONTRACTS HAVE BEEN AUDITED, USE AT YOUR OWN RISK

Link to the Koinos AssemblyScript SDK documentation: https://roaminroe.github.io/koinos-sdk-as/

Installation

# clone this repo
git clone https://github.com/roaminroe/koinos-sdk-as-examples

# with npm
npm install

# or

# with yarn
yarn install

Important note

  • It important that your smart contract file lives in the assembly folder of your project. (i.e.: ./calculator/assembly/Calculator.ts)
  • And, it is also important that your proto files live in the assembly/proto/ folder of your project. (i.e.: ./calculator/assembly/proto/calculator.proto)

Build examples

To build a Smart Contract you can use the CLI koinos-sdk-as-cli. It will help you generate all the files required to build your smart contract.

# see the cli help
yarn exec koinos-sdk-as-cli help
# example for building the calculator contract
# build the debug version (execute command in the "calculator" folder)
yarn exec koinos-sdk-as-cli build-all debug calculator.proto 

# build the release version (execute command in the "calculator" folder)
yarn exec koinos-sdk-as-cli build-all release calculator.proto 

This will result in the generation of:

  • a calculator.abi file in the folder calculator/abi/
  • a calculator-abi.json file in the folder calculator/abi/
  • a contract.wasm file in the folder calculator/build/release and calculator/build/debug
  • an index.ts file in the folder calculator/assembly/
  • a Calculator.boilerplate.ts file in the folder calculator/assembly/

Generate AssemblyScript files for all the proto files of a contract

# example for the calculator contract (execute command in the "calculator" folder)
yarn exec koinos-sdk-as-cli generate-contract-proto

Generate ABI file

# example for the calculator contract (execute command in the "calculator" folder)
yarn exec koinos-sdk-as-cli generate-abi calculator.proto

This will generate a calculator.abi file in the folder calculator/abi/

Generate contract.boilerplate.ts and index.ts files

# example for the calculator contract (execute command in the "calculator" folder)
yarn exec koinos-sdk-as-cli generate-contract-as calculator.proto

This will generate a Calculator.boilerplate.tsfile and index.ts file in the folder calculator/assembly/

Run tests

# example for the calculator contract (execute command in the "calculator" folder)
yarn exec koinos-sdk-as-cli run-tests

koinos-as-sdk-examples's People

Contributors

roaminro avatar

Watchers

James Cloos 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.