1.0.10 • Published 4 months ago

ctc2abi v1.0.10

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

ctc2abi

Generates arc-4 interface description object from reach contract handle.

Features

  • Translates reach contract handle to arc-4 interface description object.
  • Supports readonly menthods.

Installation

Install with npm:

npm install ctc2abi

usage

Import the module and call the generateABI function with the reach contract handle as argument. The function returns a promise that resolves to the arc-4 interface description object.

Write interface description object to file

import * as backend from "./build/index.main.mjs";
import { generateABI } from "ctc2abi";
import { loadStdlib } from "@reach-sh/stdlib";
import fs from "fs";
const stdlib = loadStdlib(process.env);
const zeroAddress =
  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ";
const accZero = await stdlib.connectAccount({ addr: zeroAddress });
const ctcZero = accZero.contract(backend);
const schema = await generateABI(ctcZero);
try {
  fs.writeFileSync("contract.json", JSON.stringify(schema));
  // file written successfully
} catch (err) {
  console.error(err);
}
//{
//  "name": "YourContractName",
//  "desc": "Description of your contract",
//  "methods": [
//    {
//      "name": "_reachp_0",
//      "args": [{ "type": "uint64" }, { "type": "(byte[67],address)" }],
//      "returns": { "type": "void" }
//    },
//    ...

additional information

arc-4
interface description object
reach contract handle

1.0.10

4 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago