WebAssembly Module
Each smart contract is a WebAssembly module with exported functions, and has access to specific node ABIs. We will see these ABIs in the next chapter.
WebAssembly code is compiled from AssemblyScript, a language created specifically for WebAssembly.
AssemblyScript is very similar to TypeScript, but there are some important differences to keep in mind. For example, the basic types in AssemblyScript directly expose all integer and floating-point types available in WebAssembly. Union types and optional arguments/properties are not supported in AssemblyScript, and all objects are statically typed and do not allow for dynamically changing properties. Additionally, AssemblyScript does not support exceptions catching or closures yet.
To learn more about AssemblyScript, WebAssembly modules, and ABIs, we invite you to check out the following resources:
- AssemblyScript home page, its book and its introduction from a JS perspective.
- WebAssembly home page and MDN version.
- Wikipedia explaination of the concept of ABI.
Do not initialize a smart contract project following AssemblyScript documentation. It will be unnecessarily painful. Go back to the the "Hello, World" dApp tutorial or use the following command:
npx clear-npx-cache && npx @massalabs/sc-project-initializer@buildnet init my-first-sc && cd my-first-sc