Patract Tutorial Series#1|Ask!Part 1 — wasm smart contract with TypeScript/AssemblyScript

What is Ask!

Why Ask!

First Ask! project — Flipper

Setup Ask! env

mkdir flippercd flippernpx pl-ask-cli init
@contractclass Flipper {    @state flag: bool;    constructor() {    }    @constructor    default(initFlag: bool): void {        this.flag = initFlag;    }    @message    flip(): void {        const v = this.flag;this.flag = !v;}    @message({"mutates": false})    get(): bool {        return this.flag;    }}

Decorators

Compile the contract using ask-cli

metadata.json

Event

import {AccountId, msg, Event} from "ask-lang";@eventclass Flip extends Event {    from: AccountId;    flip_result: bool;    constructor(from: AccountId,  flip_result: bool) {      super();      this.from = from;      this.flip_result = flip_result;    }}
@messageflip(): void {    const v = this.flag;    this.flag = !v;    (new Flip(msg.sender, this.flag)).emit();}
"events": [  {    "name": "Flip",    "args": [      {        "indexed": false,        "type": {          "type": 3,          "displayName": [            "AccountId"          ]        },        "docs": [          ""        ],        "name": "from"        },        {          "indexed": false,          "type": {          "type": 1,          "displayName": [            "bool"          ]        },        "docs": [          ""        ],        "name": "flip_result"      }    ],    "docs": []  }],
@topic from: AccountId;
    {      "indexed": true,      "type": {        "type": 3,        "displayName": [          "AccountId"        ]      },      "docs": [        ""      ],      "name": "from"    },

About Patract Labs

Patract is providing solutions for the development of Parachains and DApps in the Wasm smart contract ecosystem of Polkadot.