GithubHelp home page GithubHelp logo

fi-compiler's Introduction

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

fi-compiler's People

Contributors

stephenandrews avatar richayotte avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.