Fanout Transaction

Fanout Transaction

Fanout transaction allows you to fanout unspent into multiple outputs on a wallet.

Note:
This works only in the UTXO base chains.

// Get Wallet Instance
        let walletInstance = await liminalJs
            .Coin(CoinsEnum.ltc)
            .Wallets()
            .Get({ walletId: 296 });
      
        // Create Fanout Transaction    
        let response = await walletInstance.FanoutTransaction({
            feeRate: 10,
            minValue: 0.00001,
            maxValue: 100000,
            numUnspentsToMake: 5,
            maxNumInputsToUse: 1,
            targetAddress: "MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj"
        });
      
        // SignTransaction
        let halfSigned = await walletInstance.SignTransaction(null, response.data);
        console.log("halfSigned Transaction: => ", JSON.stringify(halfSigned));
      
        // Add your Sequence Id
        let sequenceId = Guid.create().toString();
        
        // Submit Transaction
        let transactionResponse = await walletInstance.Submit(halfSigned, sequenceId); // Send Many Transaction
        console.log("Consolidate Transaction: =>", JSON.stringify(transactionResponse));
// Get Wallet Instance
        let walletInstance: Wallet = await liminalJs
            .Coin(CoinsEnum.ltc)
            .Wallets()
            .Get({ walletId: 296 });

        // Create Consolidate Transaction    
        let response:FanoutTxResultWrapper=await walletInstance.FanoutTransaction({
                feeRate: 10,
                minValue:0.00001,
                maxValue: 100000,
                numUnspentsToMake: 5,
                maxNumInputsToUse: 1,
                targetAddress: "MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj"
        });

        // SignTransaction
        let halfSigned:SignedTransaction=await walletInstance.SignTransaction(null, response.data);
        console.log("halfSigned Transaction: => ", JSON.stringify(halfSigned));

        // Add your Sequence Id
        let sequenceId=Guid.create().toString();

        // Submit Transaction
        let transactionResponse:any=await walletInstance.Submit(halfSigned,sequenceId); // Send Many Transaction
        console.log("Consolidate Transaction: =>", JSON.stringify(transactionResponse));

Parameter:

Params

Data Type

Description

feeRate

number

Fees per byte

minValue

number

Minimum utxo value. Default: 0.000001

maxValue

number

Maximum utxo value.

numUnspentsToMake

number

Number of outputs to be created. Default: 1. Max: 200

maxNumInputsToUse

number

Number of inputs to be used. Default: 200. Max: 200

targetAddress

string

Address to be used for generated output

Note:
If numUnspentsToMake is more than 1, then the amount will be equally divided in each output. The minimum output amount for the whole transaction should be greater than 0.001.

You will get the following response from the ConsolidateTransaction method. It is JSON representation Only.

{
   "success":true,
   "data":{
      "txHex":"70736274ff01007c020000000283e509a64cbbf1294c7c7393e2cfed0420c4574aecee8e38151a275682c0299e0000000000ffffffff83e509a64cbbf1294c7c7393e2cfed0420c4574aecee8e38151a275682c0299e0100000000ffffffff011edc8e000000000017a914ed2f8a5488871d87f048ded565498feaad9d7ab08700000000000100fdb701020000000001015b908536ded26f8b07eda5636bfd13ce2ccddaad980f24eeb313981ce4bd8d1200000000232200204a0e149186f20a2981605b83c140108dc726c134021b2bf954eec1ab45cb450fffffffff02057847000000000017a914ed2f8a5488871d87f048ded565498feaad9d7ab087057847000000000017a914ed2f8a5488871d87f048ded565498feaad9d7ab0870400473044022012945375e953cd0d6aee62a2e8c5f9be24ed13e13354f5c0d27e36c26930de1902207cf8069548e47a6c99730c9908f6016667a559da3681937b54c15db1bc8c94e50148304502210098d79e3fcb7fd2e5357c87f784b963197e5602e4f8cfd20e0469ac33075eccd802205c85540741afa55693e1bdd7bf885b393ef27e7b27b8961a242a9a9f0934bdfd018b5221020bc37273befd8e61692dbe2071d37bb716445e50803db94e3c0ac0563e4749c22102a9dfe00d0b061a9e9dadca0fe56e83b24edf610a2a27ff983f19621d6851a5f02102f00eefd123247a953ba7416bffa413ce73d08efdeeb7afc004ba063d612fa0322102fcdf11ae3a5c26364b146f6089c0bd4d5eeae142c719fb3bc8e762e7a6f5486f54ae0000000001042200204a0e149186f20a2981605b83c140108dc726c134021b2bf954eec1ab45cb450f01058b5221020bc37273befd8e61692dbe2071d37bb716445e50803db94e3c0ac0563e4749c22102a9dfe00d0b061a9e9dadca0fe56e83b24edf610a2a27ff983f19621d6851a5f02102f00eefd123247a953ba7416bffa413ce73d08efdeeb7afc004ba063d612fa0322102fcdf11ae3a5c26364b146f6089c0bd4d5eeae142c719fb3bc8e762e7a6f5486f54ae000100fdb701020000000001015b908536ded26f8b07eda5636bfd13ce2ccddaad980f24eeb313981ce4bd8d1200000000232200204a0e149186f20a2981605b83c140108dc726c134021b2bf954eec1ab45cb450fffffffff02057847000000000017a914ed2f8a5488871d87f048ded565498feaad9d7ab087057847000000000017a914ed2f8a5488871d87f048ded565498feaad9d7ab0870400473044022012945375e953cd0d6aee62a2e8c5f9be24ed13e13354f5c0d27e36c26930de1902207cf8069548e47a6c99730c9908f6016667a559da3681937b54c15db1bc8c94e50148304502210098d79e3fcb7fd2e5357c87f784b963197e5602e4f8cfd20e0469ac33075eccd802205c85540741afa55693e1bdd7bf885b393ef27e7b27b8961a242a9a9f0934bdfd018b5221020bc37273befd8e61692dbe2071d37bb716445e50803db94e3c0ac0563e4749c22102a9dfe00d0b061a9e9dadca0fe56e83b24edf610a2a27ff983f19621d6851a5f02102f00eefd123247a953ba7416bffa413ce73d08efdeeb7afc004ba063d612fa0322102fcdf11ae3a5c26364b146f6089c0bd4d5eeae142c719fb3bc8e762e7a6f5486f54ae0000000001042200204a0e149186f20a2981605b83c140108dc726c134021b2bf954eec1ab45cb450f01058b5221020bc37273befd8e61692dbe2071d37bb716445e50803db94e3c0ac0563e4749c22102a9dfe00d0b061a9e9dadca0fe56e83b24edf610a2a27ff983f19621d6851a5f02102f00eefd123247a953ba7416bffa413ce73d08efdeeb7afc004ba063d612fa0322102fcdf11ae3a5c26364b146f6089c0bd4d5eeae142c719fb3bc8e762e7a6f5486f54ae0000"
   }
}

Full Example

import { CoinsEnum,LiminalEnvironment, LiminalJs } from "@lmnl/liminaljs";
import { Guid } from "guid-typescript";

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 });
         
         // Create Fanout Transaction    
        let response = await walletInstance.FanoutTransaction({
            feeRate: 10,
            minValue: 0.00001,
            maxValue: 100000,
            numUnspentsToMake: 5,
            maxNumInputsToUse: 1,
            targetAddress: "MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj"
        });
      
        // SignTransaction
        let halfSigned = await walletInstance.SignTransaction(null, response.data);
        console.log("halfSigned Transaction: => ", JSON.stringify(halfSigned));
      
        // Add your Sequence Id
        let sequenceId = Guid.create().toString();
        
        // Submit Transaction
        let transactionResponse = await walletInstance.Submit(halfSigned, sequenceId); // Send Many Transaction
        console.log("Consolidate Transaction: =>", JSON.stringify(transactionResponse));
    }
    catch (ex) {
        throw ex;
    }
};
main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));
import {
    CoinsEnum,
    FanoutTxResultWrapper,
    LiminalEnvironment,
    LiminalJs,
    SignedTransaction,
    Wallet
} from "@lmnl/liminaljs";
import { Guid } from "guid-typescript";

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 });

        // Create Consolidate Transaction    
        let response:FanoutTxResultWrapper=await walletInstance.FanoutTransaction({
          feeRate: 10,
          minValue:0.00001,
          maxValue: 100000,
          numUnspentsToMake: 5,
          maxNumInputsToUse: 1,
          targetAddress: "MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj"
        });

        // SignTransaction
        let halfSigned:SignedTransaction=await walletInstance.SignTransaction(null, response.data);
        console.log("halfSigned Transaction: => ", JSON.stringify(halfSigned));

        // Add your Sequence Id
        let sequenceId=Guid.create().toString();

        // Submit Transaction
        let transactionResponse:any=await walletInstance.Submit(halfSigned,sequenceId); // Send Many Transaction
        console.log("Consolidate Transaction: =>", JSON.stringify(transactionResponse));

    }
    catch (ex) {
        throw ex;
    }
}

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

Did this page help you?