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

@harmoniclabs/uplc

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmoniclabs/uplc

Typescript/Javascript representation of UPLC (Untyped PLutus Core).

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
279
decreased by-71.15%
Maintainers
1
Weekly downloads
 
Created
Source

@harmoniclabs/uplc

Typescript/Javascript representation of UPLC (Untyped PLutus Core).

Install

npm install @harmoniclabs/uplc

Getting started

parse and print uplc form flat hex (@harmoniclabs/uint8array-utils works in every js runtime)

import { fromHex } from "@harmoniclabs/uint8array-utils";
import { parseUPLC, prettyUPLC } from "@harmoniclabs/uplc";

const serialized: Uint8Array = fromHex( "0100003233700900219b8248050005200801" );

const program = parseUPLC( serialized, "flat" );

console.log(
    prettyUPLC(
        program.body, // UPLCTerm 
        4 // indentation spaces
    )
);
/*
expected output:

[
    (lam a 
        [
            [
                (builtin addInteger) 
                (con integer 2)
            ] 
            [
                [
                    (builtin multiplyInteger) 
                    (con integer 10)
                ] 
                a
            ]
        ]
    ) 
    (con integer 4)
]
    
*/

compile UPLC

import { toHex } from "@harmoniclabs/uint8array-utils";
import { Application, Builtin, UPLCConst, compileUPLC, UPLCProgram } from "@harmoniclabs/uplc";

const body = new Application(
    new Application(
        Builtin.addInteger,
        UPLCConst.int( 2 )
    ),
    UPLCConst.int( 2 )
);

const compiled = compileUPLC(
    new UPLCProgram(
        [1,0,0],
        body
    )
).toBuffer().buffer;

console.log( toHex( compiled ) );// expected output: "01000033700900224009"

FAQs

Package last updated on 02 May 2023

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