Giter VIP home page Giter VIP logo

chia-utils's Introduction

Unofficial Library: Chia-Utils

Version Version Monthly Downloads

A set of JavaScript utilities to facilitate conversions for the Chia network

Table of Contents

Install

To install from NPM:

npm install chia-utils

To install from GitHub:

git clone https://github.com/CMEONE/chia-utils.git

To test:

npm install
npm test

To include from NPM:

const { address_to_puzzle_hash, puzzle_hash_to_address, get_coin_info, get_coin_info_mojo, bytes_to_hex, hex_to_bytes } = require("chia-utils");

To include from file:

const { address_to_puzzle_hash, puzzle_hash_to_address, get_coin_info, get_coin_info_mojo, bytes_to_hex, hex_to_bytes } = require("./chia-utils.js");

To use in the browser:

<script type="text/javascript" src="chia-utils.js"></script>
<script>
  ChiaUtils.address_to_puzzle_hash( ... )
  ChiaUtils.puzzle_hash_to_address( ... )
  ChiaUtils.get_coin_info( ... )
  ChiaUtils.get_coin_info_mojo( ... )
  ChiaUtils.bytes_to_hex( ... )
  ChiaUtils.hex_to_bytes( ... )
</script>

Address to Puzzle Hash

let puzzle_hash = address_to_puzzle_hash(address);

Parameters:

  • address: string ("xch1...")

Return type: string ("0x...")

Puzzle Hash to Address

let address = puzzle_hash_to_address(puzzle_hash);

Parameters:

  • puzzle_hash: string ("0x...")

Return type: string ("xch1...")

Get Coin Info

let coin_info = get_coin_info(parent_coin_info, puzzle_hash, amount_decimal);

Parameters:

  • parent_coin_info: string ("0x...")
  • puzzle_hash: string ("0x...")
  • amount_decimal: number (0.01)

Return type: string ("0x...")

Get Coin Info Mojo

let coin_info = get_coin_info_mojo(parent_coin_info, puzzle_hash, amount);

Parameters:

  • parent_coin_info: string ("0x...")
  • puzzle_hash: string ("0x...")
  • amount: number (1000000000000)

Return type: string ("0x...")

Bytes to Hex

let hex = bytes_to_hex(bytes);

Parameters:

  • bytes: Array or Uint8Array ([0, 255, ...])

Return type: string ("fedcba9876543210...")

Hex to Bytes

let bytes = hex_to_bytes(hex);

Parameters:

  • hex: string ("fedcba9876543210...")

Return type: Uint8Array ([0, 255, ...])

chia-utils's People

Contributors

cmeone 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.