npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fi-compiler

v0.2.0

Published

Core compiler library for fi, a high-level language for Michelson

Downloads

4

Readme

fi - Smart Contract language for Tezos

fi (pronounced fee) is a powerful, smart contract language for Tezos that compiles down to valid and verifiable Michelson code. fi is currently in early alpha stages - please use at your own risk, and validate any compiled code.

Check us out online, or read through our Documentation to get started.

Installation

Node.js

You can install the npm plugin:

npm install fi-compiler

You can the include the installed module:

var fi = require("fi-compiler");

Web

You can also build a distributable version to be included on the web:

npm run build

This will generate a file within the dist directory. You can download and use the currently built dist file as well.

<script src="fi-compile.min.js"></script>

This will expose a global function, fi:

console.log(fi);

CLI

You can also install our npm CLI plugin, which allows you to compile fi directly from the command line:

npm i -g fi-cli

You can then compile code directly from your terminal using:

fi compile test_contract.fi

This will output two files in the same directory as the target fi file: xx.fi.abi => The contract ABI xx.fi.ml => The compuled michelson code

Usage

You can use the following exposed functions when using the web or node.js library:

fi.version

This returns the current version number of the fi-compiler.

console.log(fi.version);

fi.compile(code, config)

This takes one input argument, a string containing fi compile. This returns an object with two elements, code and abi.

var ficode = `
storage string name;
entry changeName(string name ){
  storage.name = input.name;
}
`;
var compiled = fi.compile(ficode);
console.log(compiled.ml); //Michelson code
console.log(compiled.abi); //ABI JSON string

You can also parse a config object, which is optional. The default settings are:

  • ml_format - defaults to "optimized" for minimal michelson, can set as "readable" for a human readable version, or "array" for a JS array
  • abi_format - defaults to "optimized" for the bare minimum, can be set as "full" for a full ABI copy including an array representation of the fi code
  • macros - WIP

fi.abi.load(abi)

You can manually loan an ABI string, which can be used to build input parameters for contract calls. In future, we aim to add additional support for more helper functions.

fi.abi.load(compiled.abi);

fi.abi.entry(entry, input)

This function allows you to convert a JSON input object into packed bytes for calling a contract using a loaded ABI file. This function takes two input arguments, the name of the function you are calling, and the JSON object with the input.

var input = {
  name : "Stephen"
};
console.log(fbi.abi.entry("changeName", input)); // Returns packed bytes for a contract call