PHP
PHP client library for interacting with LTO Network

Installation

1
composer require lto/api
Copied!

Usage

1
use LTO\Transaction\Transfer;
2
use LTO\PublicNode;
3
4
// Create account for signing
5
$seedText = "manage manual recall harvest series desert melt police rose hollow moral pledge kitten position add";
6
7
$factory = new LTO\AccountFactory('T'); // 'T' for testnet, 'L' for mainnet
8
$account = $factory->seed($seedText);
9
10
// Public layer
11
$node = new PublicNode('https://nodes.lto.network');
12
13
$amount = 1000.0; // Amount of LTO to transfer
14
$recipient = "3Jo1JCrBvnWCg37VDxMXAjYhsS9rRDLBSze";
15
16
$transferTx = (new Transfer($amount, $recipient))
17
->signWith($account)
18
->broadcastTo($node);
19
20
// Private layer
21
$body = [
22
'$schema' => "http://specs.example.com/message",
23
'content' => "Hello world!",
24
];
25
26
$chain = $account->createEventChain();
27
$chain->addIdentity($account->asIdentity())->signWith($account);
28
$chain->add(new Event($body))->signWith($account);
29
Copied!
Last modified 6mo ago
Copy link