L1X Developer SDK
Get Started
Get Started
  • L1X VM SDK
    • L1X Native SDK for L1X VM
      • Set up Environment
        • Pre-Requisites
        • Installation
          • Install Cargo L1X
            • Ubuntu and Windows (WSL)
            • Mac (Intel and Silicon)
          • Install L1X CLI (Beta)
      • Build your First Smart Contract on L1X VM
        • Common Flags and Arguments
    • L1X CLI Methods
  • L1X EVM SDK
    • Pre-Requisites
    • Hardhat Installation & Deploy your First L1X EVM FT Contract
  • L1X Typescript SDK
    • L1X Library
      • L1X Typescript SDK
      • Account Methods
        • How to import wallet using mnemonic?
        • How to import wallet using private key?
      • Core Methods
        • How to get Account State?
        • How to get block information by block number?
        • How to get chain state?
        • How to get events?
        • How to get current nonce?
        • How to get account transactions?
        • How to get the transaction recipt?
        • How to broadcast transactions?
      • L1X VM Methods
        • How to deploy a VM contract?
        • How to initialise a VM contract?
        • How to make VM readonly calls?
        • How to make VM contract state changing calls?
      • L1X EVM Methods
        • How to initialise a smart contract?
        • How to make an EVM contract state changing call?
        • How to make EVM read only calls?
      • Other Methods
        • Native Token Methods
          • How to transfer native token?
          • How to get native token balance?
          • How to get signed payload for transfer?
        • Fungible Token Methods
          • How to create fungible tokens?
          • How to mint fungible token?
          • How to give approval to fungible token?
          • How to get fungible token attributes?
          • How to get a fungible token balance?
          • How to get an allowence of fungible tokens?
          • How to transfer fungible tokens?
          • How to use transfer from of fungible token?
        • Non-fungible Token Methods
          • How to Create a Non-Fungible Token?
          • How to mint a Non-Fungible Token?
          • How to get the balance of a Non-Fungible token?
          • How to get the attribute of a Non-Fungible token?
          • How to approve a spender to manage a specific Non-Fungible token?
          • How to set or revoke approval for a specific operator to manage all tokens of the sender?
          • How to get the owner of a Non-Fungible token by its ID?
          • How to Transfer a Non-Fungible token from one address to another?
          • How to burn an existing Non-Fungible Token?
  • Endpoints
  • Configuring MetaMask with L1X Network
Powered by GitBook
On this page
  • Create L1X Project using cargo-l1x
  • Compile L1X Project
  • Create Wallet
  • Import Wallet
  • Set Default Wallet
  • Deploy L1X Project
  • Initialize L1X Project
  • Call Readonly Function
  • Call State Changing Function
  1. L1X VM SDK
  2. L1X Native SDK for L1X VM

Build your First Smart Contract on L1X VM

Create L1X Project using cargo-l1x

Initiate a new L1X project creation process with Cargo's L1X plugin. The Fungible Token template is utilized here.

cargo l1x create project_name --template ft

This command initiates the creation of a new project named "project_name" while applying the template labeled "ft". Templates offer pre-configured project structures or boilerplate code, streamlining the initial setup of your project.

Compile L1X Project

Navigate to the project directory and compile the L1X project using cargo-l1x build.

cd project_name
cargo l1x build

You will get object file for the compiled contract, at the location target/l1x/release/l1x_ft.o in cargo.

Create Wallet

Create your own wallet to generate a new keypair.

l1x-cli-beta wallet create

Import Wallet

Import you existing wallet using the l1x-cli-beta tool, by providing a private key. If you don't have one, Create Wallet.

l1x-cli-beta wallet import <PRIVATEKEY>

Set Default Wallet

After Importing your wallet set it to be the default interaction account.

l1x-cli-beta wallet default <Wallet_Address>

-- Check Endpoints for TestNet Faucet

Deploy L1X Project

Deploy the compiled L1X project to the L1X blockchain.

l1x-cli-beta contract deploy CONTRACT_OBJECT_FILE_PATH [--endpoint] [--from] [--fee_limit] [--nonce]
  • Example

l1x-cli-beta contract deploy ./sample_object_file/l1x_ft.o --endpoint https://v2-testnet-rpc.l1x.foundation

You will get deployed contract address (DEPLOY_CONTRACT_ADDRESS) as the response of the above command. Use it to initialize your L1X project.

Initialize L1X Project

Initialize your deployed L1X project by setting up its base contract address.

l1x-cli-beta contract init CONTRACT_ADDRESS --args [--endpoint] [--from] [--fee_limit] [--nonce]
  • Example

l1x-cli-beta contract init DEPLOY_CONTRACT_ADDRESS --endpoint https://v2-testnet-rpc.l1x.foundation --fee_limit 100000 --args '{"metadata":{"name": "TokenName","decimals": 18,"symbol": "TokenSymbol"},"account_ids":[],"amounts":[]}'

On successful initialization of the project, you will get initialized contract address (INIT_CONTRACT_ADDRESS) as the response of the init command. Use it for further Readonly and State Changing Function calls.

Call Readonly Function

Execute any readonly function of an L1X smart contract.

l1x-cli-beta contract view CONTRACT_ADDRESS FUNCTION --args [--endpoint] [--from]
  • Example

l1x-cli-beta contract view INIT_CONTRACT_ADDRESS ft_name --endpoint https://v2-testnet-rpc.l1x.foundation

Call State Changing Function

Invoke a state-changing function of an L1X smart contract using l1x-cli-beta, potentially altering the contract's state

l1x-cli-beta contract call INIT_CONTRACT_ADDRESS FUNCTION --args [--endpoint] [--from] [--fee_limit] [--nonce]

PreviousInstall L1X CLI (Beta)NextCommon Flags and Arguments

Last updated 1 year ago