Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/perlin-network/smart-contract-as
Write WebAssembly smart contracts for Wavelet in AssemblyScript.
https://github.com/perlin-network/smart-contract-as
assemblyscript blockchain dapp p2p smart-contracts wavelet
Last synced: about 2 months ago
JSON representation
Write WebAssembly smart contracts for Wavelet in AssemblyScript.
- Host: GitHub
- URL: https://github.com/perlin-network/smart-contract-as
- Owner: perlin-network
- Created: 2019-07-26T06:16:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-06T06:03:15.000Z (over 5 years ago)
- Last Synced: 2024-10-14T01:11:17.065Z (2 months ago)
- Topics: assemblyscript, blockchain, dapp, p2p, smart-contracts, wavelet
- Language: TypeScript
- Homepage:
- Size: 20.5 KB
- Stars: 7
- Watchers: 12
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# smart-contract-as
[![npm](https://img.shields.io/npm/v/smart-contract-as.svg)](https://www.npmjs.com/package/smart-contract-as)
[![Discord Chat](https://img.shields.io/discord/458332417909063682.svg)](https://discord.gg/dMYfDPM)Write decentralized applications for Wavelet in AssemblyScript.
## Setup
Assuming `yarn` is installed, create a new smart contract project by executing the following:
```shell
yarn add -D AssemblyScript/assemblyscript
yarn asinit .
yarn add smart-contract-as
```## Example
Inside `assembly/index.ts`:
```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.