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

eos-common

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eos-common

EOSIO Smart Contract common library used for Typescript

  • 0.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
151
increased by619.05%
Maintainers
1
Weekly downloads
 
Created
Source

eos-common

Build Status npm version MIT licensed

EOSIO Smart Contract common library used for Typescript

Goal

To implement the most commonly used EOSIO C++ Classes into Typescript:

Installation

Using Yarn:

yarn add eos-common

or using NPM:

npm install --save eos-common

Quick Start

import { Asset, Symbol } from "eos-common"

const quantity = new Asset(10000, new Symbol("EOS", 4));
quantity.toString() //=> "1.0000 EOS";
quantity.symbol.code() //=> "EOS"
quantity.symbol.precision //=> 4

API

Table of Contents

Asset

Asset

Parameters
  • amount number The amount of the asset
  • sym Symbol The name of the symbol
Examples
const quantity = new Asset(10000, new Symbol("EOS", 4));
quantity.toString() //=> "1.0000 EOS";
quantity.symbol.code() //=> "EOS"
quantity.symbol.precision //=> 4

Returns Asset Asset

amount

{int64_t} The amount of the asset

is_amount_within_range

Check if the amount doesn't exceed the max amount

Returns any true - if the amount doesn't exceed the max amount

Returns any false - otherwise

is_valid

Check if the asset is valid. %A valid asset has its amount <= max_amount and its symbol name valid

Returns any true - if the asset is valid

Returns any false - otherwise

max_amount

{constexpr int64_t} Maximum amount possible for this asset. It's capped to 2^62 - 1

check

Assert if the predicate fails and use the supplied message.

Parameters
Examples
check(a == b, "a does not equal b");

Returns void

SymbolCode

Symbol

Symbol

Parameters
Examples
const sym = new Symbol("EOS", 4);
sym.code() //=> "EOS"
sym.precision //=> 4

Returns Symbol Symbol

stake2vote

Convert EOS stake into decaying value

Parameters

vote2stake

Convert vote decay value into EOS stake

Parameters

voteWeightToday

voteWeightToday computes the stake2vote weight for EOS, in order to compute the decaying value.

split

Split quantity string

Parameters
  • quantity string Quantity string
Examples
const quantity = split("1.0000 EOS");
quantity.amount //=> 10000
quantity.symbol.precision //=> 4
quantity.symbol.code() //=> "EOS"

Returns Asset

FAQs

Package last updated on 26 Feb 2020

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