JavaScript
JavaScript / TypeScript client library for interacting with LTO Network

Installation

1
npm install lto-api @lto-network/lto-transactions --save
Copied!

Usage

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