Client for LTO Network. Integration for both public blockchain and private event-chain.
npm install @ltonetwork/lto
or
yarn add @ltonetwork/lto
Alternatively you can download the library as bundle.
The chain id is 'L' for the mainnet and 'T' testnet.
import LTO, {Binary} from '@ltonetwork/lto';
const lto = new LTO('T');
const account = lto.account();
const seed = 'satisfy sustain shiver skill betray mother appear pupil coconut weasel firm top puzzle monkey seek';
const accountFromSeed = lto.account({seed: seed});
lto.transfer(account, recipient, 100_00000000);
lto.massTransfer(account, [{recipient: recipient1, amount: 100_00000000}, {recipient: recipient2, amount: 50_00000000}]);
lto.anchor(account, new Binary('some value').hash(), new Binary('other value').hash());
lto.associate(account, 0x3400, recipient);
lto.revokeAssociation(account, 0x3400, recipient);
lto.lease(account, recipient, 10000_00000000);
lto.cancelLease(account, leaseId);
lto.sponsor(account, otherAccount);
lto.cancelSponsorship(account, otherAccount);
lto.getBalance(account);
lto.setData(account, {foo: 'bar'});
lto.getData(account);
Amounts are in LTO * 10^8
. Eg: 12.46 LTO is 12_46000000
.
For more advanced use cases, please read the documentation.
The library is also available as a bundle. This bundle includes the library and all its dependencies. This bundle is useful if you want to use the library in a browser environment.
You can download the bundle from the GitHub releases page.
The library is bundles as a UMD module. This means you can use it in the browser as a global variable, or you can import it as a module in your JavaScript code.
<script src="lto.js"></script>
<script>
const { LTO } = window.LTO;
const lto = new LTO('T');
const account = lto.account();
console.log(account.address);
</script>
Global variable LTO
is an object with all exported classes and functions. It contains the LTO
class,
which is the main class of the library. If you try to do new LTO()
you will get the error:
TypeError: LTO is not a constructor
Make sure you do
const { LTO } = window.LTO;