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
const { transfer } = require('@lto-network/lto-transactions')
2
const seed = 'some example seed phrase'
3
const signedTranserTx = transfer({
4
amount: 1,
5
recipient: '3JmEPiCpfL4p5WswT21ZpWKND5apPs2hTMB'
6
}, seed)
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!
You can also create transaction, but not sign it:
1
const unsignedTransferTx = transfer({
2
amount: 1,
3
recipient: '3JmEPiCpfL4p5WswT21ZpWKND5apPs2hTMB',
4
//senderPublicKey is required if you omit seed
5
senderPublicKey: '6nR7CXVV7Zmt9ew11BsNzSvVmuyM5PF6VPbWHW9BHgPq'
6
})
Copied!
Now you are able to POST it to LTO API or store for future purpose or you can add another signature from another party:
1
const otherPartySeed = 'other party seed phrase'
2
const transferSignedWithTwoParties = transfer(signedTranserTx, otherPartySeed)
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
const {broadcast} = require('@lto-network/lto-transactions');
2
const nodeUrl = 'https://nodes.lto.network';
3
4
broadcast(signedTx, nodeUrl).then(resp => console.log(resp))
Copied!
You can send tx to any lto node you like:. E.g.:
Last modified 6mo ago
Copy link