1.1.0 • Published 1 year ago

brah-weiroll-sdk v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Brahma Weiroll SDK

An SDK to work with weiroll scripting to generate bytecode.

Installation

npm i --save-dev brah-weiroll-sdk

(or)

yarn add -D brah-weiroll-sdk

Setup

Setup primarily requires 2 config files that are defined to comply with their interfaces -

  1. Main config

    • File name: brah-weiroll.config.json
    • Location: Directory root
    • Definition:
    interface ConfigFile {
      abiKey?: string; /// key pointing to contract abi, if the JSON file containing ABI has other data as well
      contracts: string; /// string path to contracts Config
      useForge: boolean; /// true or false to use forge file structure (abi will be read from ./out folder)
    }

    sample

  2. Contracts Config

    • File name: Can be arbitrary, but matching the contracts key on brah-weiroll.config.json
    • Location: Can be arbitrary, but matching the contracts key on brah-weiroll.config.json
    • Definition:
    interface ContractsConfig {
      [key: string]: {
        /// name of contract
        address: string; /// contract address
        abi?: string; /// string path to file containing contract abi (not required if useForge: true)
      };
    }
    • NOTE: This must contain address and abi to a 'Helper.sol' contract

    sample

Usage

  1. Instantiate VM object using

    import {BrahVM} from "brah-weiroll-sdk";
    const vm = new BrahVM();
  2. Import contracts and add functions to planner as required. Refer to sample implementation

  3. Compile VM using

    vm.compile(true);

    if the plan's bytecode is to be printed to STDOUT.

    otherwise,

    vm.compile();

License

MIT