# 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.

```bash
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.

```bash
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.

```bash
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.

```bash
l1x-cli-beta wallet import <PRIVATEKEY>
```

### **Set Default Wallet**

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

```bash
l1x-cli-beta wallet default <Wallet_Address>
```

\-- Check Endpoints for TestNet Faucet

###

### **Deploy L1X Project**

Deploy the compiled L1X project to the L1X blockchain.

```bash
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.

```bash
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

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://l1x-sdk.gitbook.io/l1x-developer-interface/interface-essentials/l1x-vm-sdk/l1x-native-sdk-for-l1x-vm/build-your-first-smart-contract-on-l1x-vm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
