@midnight-ntwrk/compact-js
v2.4.0
Published
Typescript-based execution environment for smart contracts compiled with the Compact language
Readme
Compact.js
Introduction
Compact.js provides a Typescript-based execution environment for smart contracts
compiled with the Compact language.
When a Compact smart contract is compiled with compactc, part of the output includes:
- A JavaScript file.
- A TypeScript declaration file.
The JavaScript file contains:
- The execution logic for each circuit in the source contract,
- Logic for constructing the contract’s initial state,
- Utilities for converting on-chain contract state into a JavaScript representation.
Compact.js uses this file at run time to execute the circuits. The circuit execution results are then used by higher level tools and frameworks (such as Midnight.js) in order to create and submit transactions to the Midnight blockchain. At compile time, the types and utilities of Compact.js use the TypeScript declaration file and the definitions it contains, to map types that make working with the contract and its circuits more convenient, and TypeScript idiomatic.
[!NOTE]
The term runtime is often used to describe the JavaScript executable for a contract. This is distinct from the package@midnight-ntwrk/compact-runtime, which provides the utilities that each of these JavaScript executables use.
