Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hyperionbt/helios

Package Overview
Dependencies
Maintainers
1
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperionbt/helios

Helios is a Domain Specific Language that compiles to Plutus-Core (i.e. Cardano on-chain validator scripts). Helios is a non-Haskell alternative to Plutus.

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
201
increased by116.13%
Maintainers
1
Weekly downloads
 
Created
Source

Helios Lang

Helios is a Domain Specific Language that compiles to Plutus-Core (i.e. Cardano on-chain validator scripts). Helios is a non-Haskell alternative to Plutus.

Helios is purely functional, strongly typed, and has a Rusty curly braces syntax. It notably supports closures, compile-time evaluation, and enums as tagged unions.

This repository contains a reference compiler for Helios, written in Javascript.

Use the following tutorial to learn how to use Helios with cardano-cli:

  1. Cardano-node setup
  2. Wallet setup and funding
  3. Always Succeeds contract
  4. Time Lock contract
  5. Subscription contract
  6. Minting policy scripts
  7. English Auction contract

We are in the process of migrating these tutorials here. There is an online coding playground.

Additionally the Helios library contains a function to deserialize existing Plutus-Core scripts (see second example below).

Acknowledgements

Quick start examples

1. Vesting contract example

The following Helios example is equivalent to the Plutus vesting contract from the Plutus playground:

validator vesting

struct VestingTranche {
    time:  Time // 'amount' is available after 'time'
    amount: Value

    func available_from(self, time: Time) -> Value {
        if (time >= self.time) {
            self.amount
        } else {
            Value::ZERO
        }
    }

    func remaining_from(self, time: Time) -> Value {
        self.amount - self.available_from(time)
    }
}

struct VestingParams {
    tranche1: VestingTranche
    tranche2: VestingTranche
    owner:    PubKeyHash

    func remaining_from(self, time: Time) -> Value {
        self.tranche1.remaining_from(time) + self.tranche2.remaining_from(time)
    }
}

const PARAMS: VestingParams = VestingParams{
    /*parameters interpolated from surrounding js*/
}

// the compiler is smart enough to add an empty Datum and empty Redeemer as arguments to the actual main entrypoint function
func main(ctx: ScriptContext) -> Bool {
    tx: Tx = ctx.tx;
    now: Time = tx.now();
    remaining_actual: Value = tx.value_locked_by(ctx.get_current_validator_hash());
    remaining_expected: Value = PARAMS.remaining_from(now);
    remaining_actual >= remaining_expected && tx.is_signed_by(PARAMS.owner)
}

You can compile this source into Plutus-Core using the helios.js library:

import * as helios from "helios.js"

const src = `struct VestingTranche {
...
...
`;

console.log(helios.compile(src));
// the output can be saved to a file, and that file can be used directly by cardano-cli

You can explore this example on the Helios playground.

2. Deserialize Plutus-Core

import * as helios from "helios.js"

const plutusCoreJson = `{"type": "PlutusScriptV1", ...}`;

// dump Plutus-Core AST
console.log(helios.deserializePlutusCore(plutusCoreJson));

Helios user guide and language reference

Can be found here.

FAQs

Package last updated on 11 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc