XION
DiscordGithub
  • Welcome to XION
  • XION'S Core
    • Concepts
      • Generalized Chain Abstraction
      • Intro to Account Abstraction
      • XION's Meta Accounts
      • Meta Accounts Design
      • Architecture & Tech Glossary
      • Use Cases
  • developers
    • Xion Quick Start
      • Zero to Dapp in 5 Minutes
        • Launch a User Map Dapp on XION in 5 Minutes
        • React Native Mobile Dapp on XION in 5 Minutes
      • Set Up Local Environment
        • Setting up your Local Smart Contract Development Environment for XION
          • Setting up your XION Smart Contract Development Environment on Windows (WSL2 + Ubuntu)
        • Set Up an Integrated Development Environment (IDE)
        • Interacting with Xion Chain using Xion Daemon
      • Your First Contract
        • Deploying Your First Smart Contract on XION
      • Gasless UX & Permission Grants
        • Enabling Gasless Transactions with Treasury Contracts
      • Your First DApp
        • Account Abstraction with Gasless Transactions
        • Interact with XION via your Backend Service
    • Web3 for Web2 Developers
      • Web2 vs Web3 App Architecture: A Comparison
      • Misconceptions and Misapplied Web2 Patterns
      • Recommended Architecture for Dapps on XION
    • Building for Mainnet
      • Xion Testnet: Your Development Playground
      • Building with Audited & Battle-Tested Contracts
      • Community Engagement: Building Support for Your dApp
      • Deploying to Xion Mainnet
        • Smart Contract Audits: Process, Costs & Support
        • Governance Process to Deploying Smart Contracts to Mainnet
    • Learn & Build
      • Token Factory
        • Creating, Minting, and Interacting with a Token Factory Token
        • Building a React dApp to Interact with Token Factory Tokens
        • Integrating a Token Factory Token in a Smart Contract
      • Websockets
        • WebSockets with Xion: Real-Time Communication
      • Mobile Development
        • Building a React Native Mobile App with Abstraxion (Xion.js)
      • Oracles
        • Creating a Smart Contract with Pyth Oracle Integration
      • Indexers: Optimized Data Retrieval
        • SubQuery
      • Use Cases
        • Building a Per-User Data Storage Dapp
    • Reference and Resources
      • Requesting XION Testnet Tokens
      • Public Endpoints & Resources
      • Block Explorers
      • Governance
        • Deploying Smart Contracts to Mainnet
      • Developer Tools: Abstract
      • IBC Denoms on XION Networks
      • Frequently Asked Questions
      • XION Token Contract Addresses on EVM Chains
  • Nodes & Validators
    • Run a Node
      • System Specifications
      • Build the Xion Daemon
      • Download the Xion Daemon
      • Configure the Xion Daemon
        • app.toml
        • client.toml
        • config.toml
      • Join the XION Network
        • xion-testnet-1
      • Confirm node is running
    • Become a Validator
      • Initial Setup
      • Obtain a XION Wallet Address
      • Obtain Funds
        • Testnet
      • Create Validator
    • IBC Relayers and Tokens
  • Others
    • Resources
Powered by GitBook
On this page
  • Prerequisites
  • Install WSL2 with Ubuntu
  • Set up your Linux username and password
  • Update and upgrade packages
  • Install Build Essentials and Development Tools
  • Install Docker (for CosmWasm Optimizer)
  • Setting up Visual Studio Code
  • Optimize Contract: Example
  • Clone the Repository
  • Using Visual Studio Code
  • Install xiond Binary

Was this helpful?

Edit on GitHub
  1. developers
  2. Xion Quick Start
  3. Set Up Local Environment
  4. Setting up your Local Smart Contract Development Environment for XION

Setting up your XION Smart Contract Development Environment on Windows (WSL2 + Ubuntu)

This guide walks you through setting up a local XION developer environment on a Windows machine using WSL2 with Ubuntu. This is the recommended setup for Windows users who want to work with xiond, build and interact with their CosmWasm smart contracts.

Prerequisites

  1. Windows 10 or 11 (64-bit)

Install WSL2 with Ubuntu

If you don’t have WSL2 set up, execute the following command in PowerShell:

wsl --install

The --install comand performs the following actions:

  • Set WSL2 as the default

  • Downloads and installs the default Ubuntu Linux distribution. You will need to restart your machine during the installation process.

If you want to install a different Linux distribution or another version of Ubuntu, first run the following command to view the list of available distributions:

wsl --list --online

To change the distribution installed, enter:

wsl --install -d <Distribution Name>

Replace <Distribution Name> with the name of the distribution you would like to install.

This guide assumes that you have Ubuntu installed as your Linux distribution.

Check to make sure WSL2 is set as default:

wsl --status

This should display the following "Default Version: 2".

If you're already using WSL1, you can upgrade to WSL2 using the following:

wsl --set-version Ubuntu 2

You can list your installed Linux distributions and check the version of WSL each is set to by entering the command:

wsl -l -v

Set up your Linux username and password

Click the Windows start menu button and in the search field enter "Ubuntu".

Click the Ubuntu app to open the distribution and in the terminal that's loaded you will be asked to create a User Name and Password for the Linux distribution. This User Name and Password is specific to each separate Linux distribution that you install and has no bearing on your Windows user name.

Update and upgrade packages

In the Ubuntu terminal use the following command to update the Ubuntu distribution to reduce the chance of a package not working:

sudo apt update && sudo apt upgrade

Install Build Essentials and Development Tools

sudo apt install -y build-essential pkg-config libssl-dev curl git jq unzip wget

Install Docker (for CosmWasm Optimizer)

  1. Follow the usual installation instructions to install Docker Desktop. Depending on which version of Windows you are using, Docker Desktop may prompt you to turn on WSL 2 during installation. Read the information displayed on the screen and turn on the WSL 2 feature to continue.

  1. Start Docker Desktop from the Windows Start menu.

  2. Navigate to Settings.

  3. From the General tab, select Use WSL 2 based engine..

    If you have installed Docker Desktop on a system that supports WSL 2, this option is turned on by default.

  4. Select Apply & Restart.

Once installed, make sure docker is running. You can verify that docker is installed and accessible via the Ubuntu distribution by executing:

docker --version

Setting up Visual Studio Code

Once VS Code is installed and set up, you can open your WSL project with a VS Code remote server by entering: code . .

Be sure to add the period at the end of the command to open the current directory.

Optimize Contract: Example

In this example, we’ll walk through the steps to compile a Xion smart contract using the setup described above.

Clone the Repository

Start the Ubuntu app, and in the terminal, use the following commands to clone the repository and navigate into the project directory:

git clone https://github.com/burnt-labs/cw-counter
cd cw-counter

Make sure Docker is running.

docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  cosmwasm/optimizer:0.16.0

Once compiled, the optimized contract will be available at:

./artifacts/cw_counter.wasm

Using Visual Studio Code

To optimize the contract from within Visual Studio Code, open your project using the command:

code .

This will launch the project in Visual Studio Code. From there, open a terminal within the IDE and run the Docker command above.

Install xiond Binary

PreviousSetting up your Local Smart Contract Development Environment for XIONNextSet Up an Integrated Development Environment (IDE)

Last updated 7 days ago

Was this helpful?

Follow or install Docker Desktop and enable WSL2 backend. The general steps include:

Download and install the latest version of .

Follow this step-by-step guide to , which includes installing the . This extension enables you to run WSL, SSH, or a development container for editing and debugging with the full set of Visual Studio Code features. Quickly swap between different, separate development environments and make updates without worrying about impacting your local machine.

VS Code with WSL extensions displayed

Next, compile and optimize the smart contract using the . You need to have Docker running to execute the command below:

You can now follow this to install xiond within the Ubuntu environment. It's preferable to use the Debian based installer.

Docker's official instructions for WSL2
Docker Desktop for Windows
Get started using Visual Studio Code with WSL
Remote Development extension pack
CosmWasm Optimizing Compiler
guide