Skip to content

lucas7788/ontology-wasm-cdt-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ontology-wasm-cdt-ts

Typescript library for writing ontology wasm smart contracts

Build development environment

The requirements to build Ontology wasm contarct with typescript are:

  • assemblyscript
  • ontio-ts-cdt
  • ontio-wasm-build

Create ontology wasm contract with ontio-ts-cdt

  1. create contract
npx asinit helloworld
  1. add dependencies in package.json
"dependencies": {
    "assemblyscript-json": "^0.2.0",
    "bignum": "github:MaxGraey/bignum.wasm",
    "ontio-ts-cdt": "^0.1.9"
  },
  1. change npm run asbuild:optimized of scripts in package.json
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat --validate --optimize --use abort=",
  1. edit contarct logic in assembly/index.ts
import {runtime_api,util} from 'ontio-ts-cdt';

export function invoke(): void {
  runtime_api.ret(util.stringToUint8Array('hello world'));
}

compile contract

npm run asbuild

optimized contract

ontio-wasm-build ./build/optimized.wasm

After executing this command, the optimized_optimized.wasm file will be generated. we can deploy and invoke the contract with optimized_optimized.wasm file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published