How to make an EVM contract state changing call?

  • makeStateChangingFunctionCall

Function:

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

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

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

let params: EVMStateChangeCallArg = {
  attrib: {
    arguments: {
      did: "DID_URL",
      didDocument: "DID_DOCUMENT_URL",
    },
    contract_address: "cf0289e86714d97979d726eeb2fa3a23b9c007c1",
    function: "createDID",
    abi: ["ABI"],
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit: 1,
};

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

Parameters:

The smart contract parameters for state changing object.

{
  attrib: {
    arguments: {
      did: "DID_URL",
      didDocument: "DID_DOCUMENT_URL",
    },
    contract_address: "cf0289e86714d97979d726eeb2fa3a23b9c007c1",
    function: "createDID",
    abi: ["ABI"],
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit: 1,
}

Returns:

A promise that resolves when the transaction is submitted.

{
     "hash": "dc224ba854d5fbd3371f6d509b9a0b5451fff78a70ad3a209b5c273f8da0abfb"
}

Last updated