2.1.0 • Published 2 years ago
massa-sc-utils v2.1.0
massa-sc-utils
Various utils for easily building smart contract
Requirements
- NodeJS 14+
- npm / yarn (see package.json)
Package commands
- Run
yarn install
to install all deps - Run
yarn run build
to build distribution content - Run
yarn run test
to run integration and unit tests
Smart contract utilities
The library provides methods for compiling smart contracts written in AssemblyScript with TypeScript, either via CLI or on the fly. With both methods, the returned values are a text, a binary and a base64 representation of the WASM.
Examples are shown below:
const SMART_CONTRACT_EXAMPLE = `export function add(x: number, y: number): number { return x+y };`;
const utils = new SmartContractUtils();
// compile smart contract from a typescript file with assemblycode
const compiledScFromSource: CompiledSmartContract = await utils.compileSmartContractFromSourceFile({
smartContractFilePath: "helloworld.ts",
} as WasmConfig);
// compile smart contract from a .wasm file
const compiledScFromFile: CompiledSmartContract = await utils.compileSmartContractFromWasmFile("helloworld.wasm");
// compile smart contract on the fly
const compiledScFromString: CompiledSmartContract = await utils.compileSmartContractFromString(SMART_CONTRACT_EXAMPLE);