First of all, sorry for the delayed report of Ask! v0.4 (proposal). Actually, we had released Ask! v0.4.0-rc1 (the latest version is 0.4.0-rc3) in August, since Ask! v0.4 is based on a new architecture, so we wanted to let developers try it out firstly and give us some feedback. After fixing some bugs, now I think it's time to release the report.
ask: Source code of Ask! v0.4
ask-template: A template for creating an Ask! v0.4 contract project.
ask-documentation: Documentation of Ask! v0.4
as-serde: A simple (de)serialization framework for AssemblyScript
as-serde-scale: SCALE (de)serialization library based on as-serde framework.
as-serde-json: JSON (de)serialization library based on as-serde framework.
In Ask! v0.4, we use a new architecture to design contract compilation and generation. And based on the new architecture, we redesigned the contract syntax that closer to ink! v3. In addition we also use a new and higher performance scale codec library constructed by ourselves.
Compiling a wasm smart contract with Ask! v0.3 actually goes through TWO compilation processes.
In the first compilation process, Ask! v0.3 only checks the contract syntax, and then checks the specific type and semantics for the second time. The final assemblyscript code is generated by splicing strings, which also results in very poor readability of the generated code, and error messages are difficult to locate the problem. Even some obviously wrong contract code can pass the compilation check and generate wasm.
Although Ask! v0.3 introduced ask-cli, which is similar to the cargo-contract role in ink, to partially solve the two compilation problem, in the process of using it, we found that the original architecture + ask-cli
is not elegant, and ask-cli itself requires additional learning costs for contract developers.
After some investigation and simple verification, we use a simpler architecture to compile and generate the wasm contract code: manipulate the AST generated by the contract code through the assemblyscript toolchain to get final wasm code and metadata, without introducing additional tools (like ask-cli
or cargo-contract
) to help development of wasm contracts.
In this way, the generated assemblyscript code has better readability, and the type checking and error messages have been greatly improved. And the contract development will only involve the assemblyscript toolchain and Ask! contract syntax.
Ask! v0.3 | Ask! v0.4 | |
---|---|---|
Components | 1. Contract Framework 2. Contract Preprocessor 3. ask-cli | 1. Contract Framework 2. Transform Framework |
Learning Cost | 1. assemblyscript toolchain 2. Ask contract syntax 3. ask-cli tool | 1. assemblyscript toolchain 2. Ask contract syntax |
Codec Library | forked version of as-scale-codec | our new implmentation: as-serde-scale |
For more detailed usage, please refer to our template and documentation .
Compilation && Code generation: As mentioned above, now developers only need to use a package manager (npm
or yarn
) to import assemblyscript
and ask-transform
packages to develop Ask! contracts, and directly compile and generate wasm code and metadata through the assemblyscript toolchain. See template for details.
Contract framework: We have rewritten the contract syntax framework based on the new architecture. The current Ask! contract syntax still uses the decorator syntax, but it's closer to the procedural macro style of ink! v3.
Codec: Ask! v0.3 uses a forked version of as-scale-codec (the upstream doesn't seem to be maintained anymore, last commit was a year ago) for SCALE encoding/decoding, but in Ask! v0.4, we create a new library as-serde-scale, compared with as-scale-codec, as-serde-scale has better codec performance, more complete implementation, easy to use, and it's maintained by ourselves.
We have synchronized the latest host functions of pallet-contracts, and the current syntax of Ask! v0.4 is also very close to ink! v3 style, developers can easily migrate contract code between ink! and Ask!. And the metadata.json
generated by Ask! v0.4 is also compatible with the metadata.json
generated by ink!.
Track the latest host functions of pallet-contracts
New storage design, compatible with ink! v4
Simple contract test framework
More detailed documentation
More interesting and complex examples
...