Litecoin
The Litecoin class from the @moonup/moon-api package provides methods to interact with Litecoin accounts and transactions.
Initialization
To use the Litecoin class, you need to create an instance of it by passing an instance of the HttpClient class to its constructor. The HttpClient class is also part of the @moonup/moon-api package and provides a convenient way to make HTTP requests.
Here's an example of how to create an instance of the Litecoin class:
import { HttpClient, Litecoin } from '@moonup/moon-api';
const http = new HttpClient({
baseUrl: 'https://beta.usemoon.ai',
securityWorker: async (securityData) => {
return {
headers: {
Authorization: `Bearer ${securityData.token}`,
},
};
},
});
const litecoin = new Litecoin(http);Methods
The Litecoin class provides the following methods:
createLitecoinAccount(data: LitecoinInput, params?: RequestParams): Promise<CreateLitecoinAccountData>Creates a new Litecoin account.
datais an object of typeLitecoinInputthat contains the necessary information to create the account.paramsis an optional object of typeRequestParamsthat can be used to customize the request.Returns a promise that resolves to an object of type
CreateLitecoinAccountData.
Example usage:
const data = { network: 'testnet', private_key: 'private_key', }; const result = await litecoin.createLitecoinAccount(data); console.log(result);getLitecoinAccount(accountName: string, params?: RequestParams): Promise<GetLitecoinAccountData>Retrieves information about a specific Litecoin account.
accountNameis a string that represents the name of the account.paramsis an optional object of typeRequestParamsthat can be used to customize the request.Returns a promise that resolves to an object of type
GetLitecoinAccountData.
Example usage:
const accountName = 'my_account'; const result = await litecoin.getLitecoinAccount(accountName); console.log(result);listLitecoinAccounts(params?: RequestParams): Promise<ListLitecoinAccountsData>Retrieves a list of all Litecoin accounts.
paramsis an optional object of typeRequestParamsthat can be used to customize the request.Returns a promise that resolves to an object of type
ListLitecoinAccountsData.
Example usage:
const result = await litecoin.listLitecoinAccounts(); console.log(result);signLitecoinTransaction(accountName: string, data: LitecoinTransactionInput, params?: RequestParams): Promise<SignLitecoinTransactionData>Signs a Litecoin transaction for a specific account.
accountNameis a string that represents the name of the account.datais an object of typeLitecoinTransactionInputthat contains the necessary information to sign the transaction.paramsis an optional object of typeRequestParamsthat can be used to customize the request.Returns a promise that resolves to an object of type
SignLitecoinTransactionData.
Example usage:
const accountName = 'my_account'; const data = { to: 'recipient_address', value: 0.1, }; const result = await litecoin.signLitecoinTransaction(accountName, data); console.log(result);
These methods can be used to perform various operations on Litecoin accounts and transactions, such as creating new accounts, retrieving account information, signing transactions, and more. The Litecoin class is a part of the @moonup/moon-api package, which provides a convenient way to interact with the Moon API.
Last updated