LTO Network
Search…
JavaScript
JavaScript / TypeScript client library for interacting with LTO Network

Installation

1
npm install lto-api --save
Copied!

Usage

1
import LTO from "@ltonetwork/lto/raw/LTO";
2
import Transfer from "@ltonetwork/lto/raw/transactions/Transfer";
3
import {PublicNode} from "@ltonetwork/lto/raw/PublicNode";
4
import {Event} from "@ltonetwork/lto/raw/events";
5
6
7
// Account
8
const lto = new LTO('T'); // 'T' for testnet, 'L' for mainnet
9
const account = lto.account();
10
11
// Public chain
12
const node = new PublicNode('https://testnet.lto.network');
13
14
const amount = 1000;
15
const recipient = "3JmEPiCpfL4p5WswT21ZpWKND5apPs2hTMB";
16
17
const transaction = new Transfer(recipient, amount);
18
transaction.signWith(account);
19
node.broadcast(transaction).then(resp => console.log(resp));
20
21
22
// Private chain
23
const chain = account.createEventChain();
24
25
const body = {
26
"$schema": "http://specs.livecontracts.io/01-draft/12-comment/schema.json#",
27
"identity": {
28
"$schema": "http://specs.livecontracts.io/01-draft/02-identity/schema.json#",
29
"id": "1bb5a451-d496-42b9-97c3-e57404d2984f"
30
},
31
"content_media_type": "text/plain",
32
"content": "Hello world!"
33
};
34
35
chain.addEvent(new Event(body).signWith(account));
Copied!
Last modified 2mo ago
Copy link