LTO Network
Search…
Public layer

Transactions

Create a transaction and sign it from a minimal set of required params. If you want to create Transfer transaction the minimum you need to provide is amount and recipient as defined in Transfer params:
1
import Transfer from "@ltonetwork/lto/raw/transactions/Transfer";
2
3
const amount = 1000;
4
const recipient = "3JmEPiCpfL4p5WswT21ZpWKND5apPs2hTMB";
5
6
const transaction = new Transfer(recipient, amount);
Copied!
You can sign a transaction with your account:
1
transaction.signWith(account);
Copied!
Output will be a signed transfer transaction:
1
{
2
id: '3sgkGCxZmPpKDz8BNztWNoVEiXXgWgeZdYpJNh1CqtKp',
3
type: 4,
4
version: 2,
5
senderPublicKey: '98Pw96PizgJC7MHT8RUDJGS7YGr68YDqmSA2X83XJeDX',
6
recipient: '3JmEPiCpfL4p5WswT21ZpWKND5apPs2hTMB',
7
amount: 1,
8
attachment: '',
9
fee: 100000,
10
timestamp: 1536917842558,
11
proofs: [
12
'4r7Amhzmpj2yh7uCiTkTjosVwKfHUTucoyitRXafzTBtQrsdqVGcJvJdneHakNq2LcsBWCxfDowkke7RbAMMZoaQ'
13
]
14
}
Copied!
Now you are able to POST it to LTO API or store for future purpose or you can decide to sponsor the transaction from another account
1
transaction.sponsorWith(otherPartyAccount);
Copied!
So now there are two proofs:
1
{
2
id: '3sgkGCxZmPpKDz8BNztWNoVEiXXgWgeZdYpJNh1CqtKp',
3
type: 4,
4
version: 2,
5
senderPublicKey: '98Pw96PizgJC7MHT8RUDJGS7YGr68YDqmSA2X83XJeDX',
6
recipient: '3JmEPiCpfL4p5WswT21ZpWKND5apPs2hTMB',
7
amount: 1,
8
attachment: '',
9
fee: 100000,
10
timestamp: 1536917842558,
11
proofs: [
12
'4r7Amhzmpj2yh7uCiTkTjosVwKfHUTucoyitRXafzTBtQrsdqVGcJvJdneHakNq2LcsBWCxfDowkke7RbAMMZoaQ',
13
'4m2GCeWc3jFg7qE7D67rzD26KTe2YMaSSz99GcxGCezBAuh6LSWBCEnDbPDfRMKDoCZDdTLgjovdF9LhDzan4Qah'
14
]
15
}
Copied!

Broadcast

To send transaction you can use either node REST API or broadcast helper function:
1
import {PublicNode} from "@ltonetwork/lto/raw/PublicNode";
2
3
const node = new PublicNode('https://nodes.lto.network');
4
5
node.broadcast(signedTx).then(resp => console.log(resp))
Copied!
You can send tx to any lto node you like:. E.g.:
Copy link