0.3.0 • Published 4 years ago

@coinbarn/ergo-ts v0.3.0

Weekly downloads
16
License
MIT
Repository
github
Last release
4 years ago

Ergo-ts

codecov Build Status

About

The library for Ergo platform, written in TypeScript, and compiled to JavaScript. It uses block explorer as the backend and allows you to transfer crypto tokens without long full node synchronization. Besides native token transfer, it supports custom tokens and more complicated features like additional registers in outputs.

Installing

Import in body

<script src='path_to/dist/ergo-ts.js'></script> 

With npm:

npm install @coinbarn/ergo-ts

Or yarn:

yarn add @coinbarn/ergo-ts

Examples

Explore current blockchain status:

import {Address, Explorer, Transaction, ErgoBox} from "@coinbarn/ergo-ts";

const explorer = Explorer.mainnet;
const address = new Address('9gsLq5a12nJe33nKtjMe7NPY7o8CQAtjS9amDgALbebv1wmRXrv');
const tokenId = '13d24a67432d447e53118d920100c747abb52da8da646bc193f03b47b64a8ac5';

// Current blockchain height
const height: Promise<number> = explorer.getCurrentHeight();

// All unconfirmed transactions
const mempoolTxs: Promise<Transaction[]> = explorer.getUnconfirmed();

// Unconfirmed transactions by address
const myMempoolTxs: Promise<Transaction[]> = explorer.getUnconfirmed(address);

// Confirmed transactions by address
const myTxs: Promise<Transaction[]> = explorer.getTransactions(address);

// Unspent outputs by address
const myBoxes: Promise<ErgoBox[]> = explorer.getUnspentOutputs(address);

// The box where the token was issued
const tokenInfo: Promise<ErgoBox> = explorer.getTokenInfo(tokenId);

Sending transactions :

import {Client} from "@coinbarn/ergo-ts";

const client = new Client('https://new-explorer.ergoplatform.com');
const sk = '8e6993a4999f009c03d9457ffcf8ff3d840ae78332c959c8e806a53fbafbbee1';
const recipient = '9gsLq5a12nJe33nKtjMe7NPY7o8CQAtjS9amDgALbebv1wmRXrv';

// send 0.019 ERG to the recipient
client.transfer(sk, recipient, 0.019);

// Issue 123456.789 Coinbarn tokens with 3 decimals each
client.tokenIssue(sk, 'Coinbarn', 123456.789, 3, 'Description of this token');

// Transfer 1.23 tokens with id 13d24a67432d447e53118d920100c747abb52da8da646bc193f03b47b64a8ac5 to the recipient
client.transfer(sk, recipient, 1.23, '13d24a67432d447e53118d920100c747abb52da8da646bc193f03b47b64a8ac5');
0.3.0

4 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.0.9

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.1.2

4 years ago

0.0.1

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago