How to initialise a smart contract?

  • init

Function:

This function is used to Initialise a smart 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: {
    base_contract_address: "604df657c9dd8de7a1e0acf6590bb7c0516740ee",
    arguments: {},
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit: 1,
};

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

Parameters:

The smart contract initialisation object

{
  attrib: {
    base_contract_address: "604df657c9dd8de7a1e0acf6590bb7c0516740ee",
    arguments: {},
  },
  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