How to deploy a VM contract?

  • deploy

Function:

The function is used to deploy the smart contract.

import { L1XProvider, VMDeployArg } from "@l1x/l1x-wallet-sdk";
import fs from "fs/promises";

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

(async () => {
    let params: VMDeployArg = {
        attrib: {
            base_contract_bytes: await fs.readFile("./l1x_nft.o"),
        },
        private_key: "YOUR_PRIVATE_KEY"
    };

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

Parameters:

The VM contract deploy object

 attrib: {
            base_contract_bytes: await fs.readFile("./l1x_nft.o"),
        },
private_key: "YOUR_PRIVATE_KEY"

Returns:

A promise that resolves when the transaction is submitted.

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

Last updated