Avalanche SDK Client - v0.0.4-alpha.14
    Preparing search index...

    Function prepareAddAutoRenewedValidatorTxn

    • Prepares an add auto-renewed validator transaction for the P-chain.

      Parameters

      Returns Promise<PrepareAddAutoRenewedValidatorTxnReturnType>

      The unsigned transaction. PrepareAddAutoRenewedValidatorTxnReturnType

      import { prepareAddAutoRenewedValidatorTxn } from "@avalanche-sdk/client/methods/wallet/pChain/prepareAddAutoRenewedValidatorTxn";
      import { createAvalancheWalletClient } from "@avalanche-sdk/client/clients/createAvalancheWalletClient";
      import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts";
      import { avalanche } from "@avalanche-sdk/client/chains";
      import { avaxToNanoAvax } from "@avalanche-sdk/client/utils";

      const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890");
      const walletClient = createAvalancheWalletClient({
      account,
      chain: avalanche,
      });

      const pChainAddAutoRenewedValidatorTxnRequest = await prepareAddAutoRenewedValidatorTxn(walletClient, {
      nodeId: "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg",
      stakeInNanoAvax: avaxToNanoAvax(2000),
      period: 1209600n,
      rewardAddresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"],
      delegatorRewardAddresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"],
      ownerAddresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"],
      publicKey: "0x85025bca6a302dc61338ff49c8baa572ded3e86f3759304c7f618a2a2593c187e080a3cfdec95040309ad1f158953067",
      signature: "0x85ee50110f99f4cf5822ea3c8c9e6941a7f1ab94678e6ba784cd7609492855dc440c37ac605e45f5bd9c63ac13ce06550513264195f87d8e2c78818a51dcba95565f197e3f63962ad566d3c524fc878c4f59ec2d1da5bb042fd99da5",
      delegatorRewardPercentage: 2.5,
      autoCompoundRewardPercentage: 100,
      });

      console.log(pChainAddAutoRenewedValidatorTxnRequest);