How to initialise a VM contract?

  • init

Function:

This function is used to Initialise a VM contract.

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

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

let params: VMInitArg = {
  attrib: {
    arguments: {},
    base_contract_address: "1e6c0451505da3afeb1ed547b0cbfeefa40bfd15",
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit: 1,
};

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

Parameters:

The VM contract initialisation object

{
  attrib: {
    arguments: {},
    base_contract_address: "1e6c0451505da3afeb1ed547b0cbfeefa40bfd15",
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit: 1,
}

Returns:

A promise that resolves when the transaction is submitted.

{
     "contract_address": "cf0289e86714d97979d726eeb2fa3a23b9c007c1",
     "hash": "dc224ba854d5fbd3371f6d509b9a0b5451fff78a70ad3a209b5c273f8da0abfb"
}

Last updated