UNPKG

@massalabs/massa-sc-utils

Version:
49 lines (33 loc) 1.55 kB
# massa-sc-utils Massa utils for easy compilation and deployment of smart contract written in AssemblyScript ### Requirements * NodeJS 14+ * npm / yarn (see package.json) ### Package commands 1. Run `yarn install` to install all deps 2. Run `yarn run build` to build distribution content 3. 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: ```ts const SMART_CONTRACT_EXAMPLE = `export function add(x: number, y: number): number { return x+y };`; const utils = new SmartContractUtils(); // compile smart contract from an assemblyscript file 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 from string const compiledScFromString: CompiledSmartContract = await utils.compileSmartContractFromString(SMART_CONTRACT_EXAMPLE); ``` ### Smart contract prompt scripts The package also provides scripts that allow deploying a smart contract and a webpage (.zip file): ``` npm run deploy-website ``` and ``` npm run deploy-smart-contract ```