@massalabs/massa-sc-utils
v2.2.0
Published
Massa smart contract utils
Downloads
11
Readme
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
- 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 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