Generate Address

Generate the address

This API call is used to generate the Address, Use the following code:

// Get Wallet Result
let walletResult = (await walletInstance.GetWallet()).Result;
console.log("Wallet Result : =>  ", walletResult);

// Generate Address
let address = await walletInstance.GenerateAddress(walletResult, 0);
console.log("Wallet Address Object : => ",JSON.stringfy(address));
// Get Wallet Result
let walletResult: WalletResult = (await walletInstance.GetWallet()).Result;
console.log("Wallet Result : =>  ", walletResult);

// Generate Address
let address: AddressType = await walletInstance.GenerateAddress(walletResult, 0);
console.log("Wallet Address Object : => ", JSON.stringfy(address));

Parameter:

ParamsData TypeDescription
walletResultObjectIt is a wallet result object that can generate the address.
pathIntegerSequence id, this needs to be in the incremental format for subsequent address

Sample response

{
   "path":"m/0/0",
   "balance":0,
   "type":"receive",
   "txcount":0,
   "walletid":296,
   "address":"MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj",
   "redeem":"5221020bc37273befd8e61692dbe2071d37bb716445e50803db94e3c0ac0563e4749c22102a9dfe00d0b061a9e9dadca0fe56e83b24edf610a2a27ff983f19621d6851a5f02102f00eefd123247a953ba7416bffa413ce73d08efdeeb7afc004ba063d612fa0322102fcdf11ae3a5c26364b146f6089c0bd4d5eeae142c719fb3bc8e762e7a6f5486f54ae"
}

Full Example

import { CoinsEnum,LiminalEnvironment, LiminalJs } from "@lmnl/liminaljs";

const main = async () => {
    try {
        // Instance of Liminal Js
        let liminalJs = new LiminalJs(LiminalEnvironment.test);
        await liminalJs
            .Authenticate({
                clientId: "YOUR_CLIENT_ID",
                clientSecret: "YOUR_CLIENT_SECRET"
            })
            .AuthenticateWithAccessToken();

        // Get Wallet Instance
        let walletInstance = await liminalJs
            .Coin(CoinsEnum.ltc)
            .Wallets()
            .Get({ walletId: 296 });

        // Get Wallet Result
        let walletResult = (await walletInstance.GetWallet()).Result;
        console.log("Wallet Result : =>  ", walletResult);
        
        // Generate Address
        let address = await walletInstance.GenerateAddress(walletResult, 0);
        console.log("Wallet Address Object : => ", address);
    }
    catch (ex) {
        throw ex;
    }
};
main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));
import {
    AddressType, CoinsEnum,LiminalEnvironment,
    LiminalJs,
    Wallet,
    WalletResult
} from "@lmnl/liminaljs"

const main = async (): Promise<void> => {
    try {
        // Instance of Liminal Js
        let liminalJs = new LiminalJs(LiminalEnvironment.test);
        await liminalJs
            .Authenticate({
               clientId: "YOUR_CLIENT_ID",
                clientSecret: "YOUR_CLIENT_SECRET"
            })
            .AuthenticateWithAccessToken();

        // Get Wallet Instance
        let walletInstance: Wallet = await liminalJs
            .Coin(CoinsEnum.ltc)
            .Wallets()
            .Get({ walletId: 296 });

        // Get Wallet Result
        let walletResult: WalletResult = (await walletInstance.GetWallet()).Result;
        console.log("Wallet Result : =>  ", walletResult);

        // Generate Address
        let address: AddressType = await walletInstance.GenerateAddress(walletResult, 0);
        console.log("Wallet Address Object : => ", address);

    }
    catch (ex) {
        throw ex;
    }
}

main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));

Did this page help you?