Skip to content
Write WebAssembly smart contracts for Wavelet in AssemblyScript.
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assembly
examples examples: add chat example, and token example Aug 6, 2019
.gitignore
README.md
index.js
package.json
yarn.lock

README.md

smart-contract-as

npm Discord Chat

Write decentralized applications for Wavelet in AssemblyScript.

Setup

Assuming yarn is installed, create a new smart contract project by executing the following:

yarn add -D AssemblyScript/assemblyscript
yarn asinit .
yarn add smart-contract-as

Example

Inside assembly/index.ts:

import {Parameters, Tag, Transfer, send_transaction, log} from "../node_modules/smart-contract-as/assembly";

// Simple hello world example.
export function _contract_init(): void {
    const params = Parameters.load();
    log("hello world");
}

// Echoes back a message the sender provides.
export function _contract_test(): void {
    const params = Parameters.load();
    log("echoing back: " + params.string());
}

// Sends back half the PERLs it receives back to the sender.
export function _contract_on_money_received(): void {
    const params = Parameters.load();

    const tx = new Transfer(params.sender_id, params.amount / 2);
    send_transaction(Tag.TRANSFER, tx.marshal());
}

For more examples, check out the examples/ directory.

You can’t perform that action at this time.