Oraichain DAO
  • Introduction
    • About Oraichain
    • Oraichain Architechure
    • Blockchain and AI Powerhouse
    • Applications and use cases
  • Setting up wallet on Oraichain
    • Intro
    • Owallet
    • How to set up Keplr
  • Getting Started
    • Testnet
    • Mainnet
      • Become a Sentry node operator by Docker
      • Build Linux binary from source and become a Sentry Node Operator
      • Running a validator node on Oraichain .
    • Setting up Oraichain dev environment
  • Cosmwasm Quick Start
    • Understanding Cosmwasm File Structure
    • Intro to writing Cosmwasm Smart contract
    • Writing CW-721 NFT Contract
    • Deploying Smart contracts on Oraichain
    • Building a Favourite number dApp
  • RPC and tooling
    • RPC Endpoints
    • Tooling and Infra
    • Developer cheatsheet
  • Welcome to Oraichain DAO
    • Governance
      • Staking to Delegate on Oraichain
      • Selecting a Validator
      • DAO Treasury
    • How to Join
Powered by GitBook
On this page
  • Install Rust 🦀
  • Add the wasm target
  • Install cargo-generate package
  • Get the boilerplate code ready
  • Installing cwtools and setting up cosmwasm ide
  1. Getting Started

Setting up Oraichain dev environment

PreviousRunning a validator node on Oraichain .NextUnderstanding Cosmwasm File Structure

Last updated 1 year ago

This tutorial will help you setup development environment for enabling you to write your first smart contract on Oraichain , which is a blockchain bridging the gap between Artificial intelligence and blockchain thus offering a world of limitless possibilities . if you wanna deep dive into the intricacies of oraichain , I encourage you to . So let’s begin.

For following along this tutorial I encourage you to working with linux , it would be really easy for you to install all dependencies in linux , if you are working on windows you can , which will basically enable you to run linux shell in your windows machine .

Install Rust 🦀

Smart contracts in Oraichain are written using Cosmwasm , which is a library for writing smart contracts in rust so we need to start by installing rust which can be done using the following steps :

Run the Command

$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

Check if you have installed rust correctly or not

For confirming your installation run the below given commands :

rustup is basically your rust manager , which manages the versions of rust , and for oraichain development we need the stable release of rust thus u should run the below command .

rustup default stable 

now confirm the installation of rust using the below

cargo version

Cargo is the package manager of rust world , it will help you install and manage all the packages and dependencies for your project .

Add the wasm target

Our smart contracts will be compiled in to wasm bytecode , which is basically a bytecode format understood by browser. Our wasm will be compiled from rust so we will be using rustup for that , to add the wasm target run the command

rustup target add wasm32-unknown-unknown

🦀 wasm32-unknown-unknown states the target specification, and is called "target triple" consisting of three strings separated by hyphens.

Strings represent architecture, vendor, and operating system respectively. unknown means there is no specifications for the target and the application is more flexible.

Now we are prepared to get some boilerplate installed into our system , so let’s move on to next step .

Install cargo-generate package

Another requirement we need to generate the boilerplate is Cargo Generate. This can be installed via CLI using commands:

cargo install cargo-generate --features vendored-openssl
cargo install cargo-run-script

cargo-generate is a command-line tool used in Rust programming for generating new Rust projects from predefined templates. It allows developers to quickly set up a new project with a specific structure, dependencies, and configuration.

Get the boilerplate code ready

Now we have installed all the dependencies to help us get started , so lets use the smart contract template by the Interwasm team for enabling us to craft smart contracts using the cosmwasm framework , simply enter the CLI command .

cargo generate --git https://github.com/CosmWasm/cw-template.git --name <PROJECT_NAME>

using the older version

cargo generate --git https://github.com/CosmWasm/cw-template.git --branch <BRANCH_NAME> --name <PROJECT_NAME>
  • —name : will basicall help us set the project name , for this project I am keeping the name hello-cw , you can keep any name of your choice

  • I am using an older version for compatibility reasons , it is up to you if you wanna use the latest release but I would suggest you to follow along

The version I will be using is 1.0-minimal. This version has minimal boilerplate so we won't have to delete much, although it isn't the latest version. So run the command:

cargo generate --git https://github.com/CosmWasm/cw-template.git --branch 1.0-minimal --name hello-cw

Here is a snapshot of how it will look , after successful installation you should be having the same output .

Now you need to check into the directory of your folder , in my case hello-cw for you it might be the name you have selected for your project .

Run the below command to enter your project directory

cd hello-cw

Installing cwtools and setting up cosmwasm ide

For installing cwtools simply enter the command

npm install -g @oraichain/cwtools

This tool can be your secret weapon as a SamOrai as it enables you to compile your smart contract and interact with it as well , we will learn more about it in further sections

Setting up cosmwasm ide

With this we have completed the required set up for starting up with Oraichain development in further sections we are going to learn about writing smart contracts and deploying them on Oraichain .

Read the for a more detailed explanation.

For installing cosmwasm ide simply install it from .after installing it locally into your machine you should be having something like this

rust docs
this link
read their whitepaper
install Windows subsystem for linux (WSL)
After running the above command you should be having these options so you can go with the first option , for standard installation . this will install rust in your system
I have rust already installed in my system , for you the output will be diffrent .
after successful installation you should be having this kind of output .
I have already set up my rustup target but for my project thus i am getting this response .
After running the first command . you should see the similar output .
after running the second command , similar out put , basically you will get the packages installed
This snapshot is of all the files we have got after generating the boilerplate contract project ,