eos-common
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 { split } from "eos-common"
const { amount } = split("1.0000 EOS");
amount
API
Table of Contents
constructor
Asset Class
Parameters
amount
sym
Symbol The name of the symbola
number The amount of the asset
Examples
const quantity = new Asset(10000, new Symbol("EOS", 4));
quantity.toString()
quantity.symbol.code()
quantity.symbol.precision
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
split
Split quantity string
Parameters
quantity
string Quantity string
Examples
const quantity = split("1.0000 EOS");
quantity.amount
quantity.symbol.precision
quantity.symbol.code()
Returns Asset
check
Assert if the predicate fails and use the supplied message.
Parameters
Examples
check(a == b, "a does not equal b");
Returns void
SymbolCode
constructor
Symbol Class
Parameters
Examples
const sym = new Symbol("EOS", 4);
sym.code()
sym.precision
Returns Symbol Symbol