How to make an VM contract state changing call?

  • makeStateChangingFunctionCall

Function:

This function is used to make a state changing call to a VM contract.

import { L1XProvider, VMStateChangeCallArg } from "@l1x/l1x-wallet-sdk";

let l1xProvider = new L1XProvider({
  clusterType: "mainnet",
  endpoint: "https://v2-mainnet-rpc.l1x.foundation",
});

let params: VMStateChangeCallArg = {
  attrib: {
    arguments: {
      token: "BNB",
      new_percentage: "113940",
      duration: "180",
    },
    contract_address: "2092b9b5fbaa7a924fae9547e6997832300fe15c",
    function: "update_token_rewards_percentage",
    is_argument_object: true,
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit: 1,
};

l1xProvider.vm
  .makeStateChangingFunctionCall(params)
  .then((response) => console.log(response)) // log response
  .catch((err) => console.error(err)); // log error

Parameters:

The VM contract parameters for state changing object.

{
  attrib: {
    arguments: {
      token: "BNB",
      new_percentage: "113940",
      duration: "180",
    },
    contract_address: "2092b9b5fbaa7a924fae9547e6997832300fe15c",
    function: "update_token_rewards_percentage",
    is_argument_object: true,
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit: 1,
}

Returns:

A promise that resolves when the transaction is submitted.

{
    "hash": "aea97cfc0478da253f51309a8297aa664267e6f10486bed5b8022ed1baca8187"
}

Last updated