LogoLogo
  • Introduction
  • Understanding Rujira History
    • Rujira & Kujira
    • Rujira & THORChain
    • Rujira & Levana
  • Understanding RUJI Token
  • HOW IT WORKS
    • Understanding the App Layer
    • Understanding Secured Assets
    • Understanding App Layer Security
    • Frequently Asked Questions
  • Developers
    • Getting Started
      • API & RPC Endpoints
      • Licenses
    • Development Process
    • Local Deployment Guide
    • Stagenet Deployment Guide
    • Review and Audit Guide
    • Setting Up a THORChain Multisig
    • Mainnet Deployment Guide
  • Core Products
    • RUJI Trade
    • RUJI Pools
      • Base Layer Arbitrage Strategy
    • RUJI Perps
      • Position size versus locked collateral
    • RUJI Lending
    • RUJI Liquidations
    • RUJI Launchpad
    • RUJI Options
    • RUJI Collections (Gojira)
    • Strategies
  • Ecosystem Products
    • RUJI Index
  • Resources
    • Branding
    • Audits
    • Discord (for Devs)
    • Telegram (for Community)
Powered by GitBook
On this page
  • Start Developing
  • 1. Writing Your Contract
  • 2. Testing
  • 3. Test Deployment
  • 4. Review & Audit
  • 5. Setup multisig as deployer address
  • 6. Mainnet Deployment
Export as PDF
  1. Developers

Development Process

PreviousLicensesNextLocal Deployment Guide

Last updated 3 days ago

THORChain builds in the open—and Rujira is no exception—hence your smart contracts code will have to be open source if you build on Rujira.

Deployments on Rujira are permissioned, we look to create a coherent suite of apps and avoid duplicates. The development process includes vetting by the Rujira team, external audits and ultimately whitelisting by THORChain's node operators for mainnet deployment. Before starting to build, please contact the Rujira team to get introduced and make sure your project fits into the bigger picture and doesn't overlap with existing plans.

Make sure to check the file before you start building on the App Layer, and take the time to check the commits of previous contracts deployed in the file.

Start Developing

This guide will walk you through the development process for building, testing, and deploying CosmWasm contracts on Rujira. It covers everything from writing your contract, performing unit and integration testing, deploying to test environments, and finally deploying to mainnet.

1. Writing Your Contract

Rujira contracts are built using CosmWasm, a smart contract platform written in Rust. Follow the steps below to get started writing your contract:

  1. Set up your environment: Ensure that you have Rust and the necessary development tools installed. You can follow .

  2. Contract Structure: CosmWasm contracts typically consist of the following components:

    • InstantiateMsg: Defines the parameters required to initialize the contract.

    • ExecuteMsg: Represents various actions that users can invoke on the contract.

    • QueryMsg: Represents read-only operations that fetch contract state.

  3. Serialization: Contracts in CosmWasm use #[cw_serde] for serialization and deserialization. Rujira may introduce a modified implementation of #[cw_serde] to provide a more compact encoding of ExecuteMsgs, especially since these messages may be inserted into Layer 1 memos for CosmWasm callbacks. This will ensure efficient handling and smaller payloads.

  4. Best Practices:

    • Organize your code into modular functions for better readability and maintenance.

    • Use meaningful types and clear names for your messages and state variables.

    • Ensure that your contract handles errors gracefully and follows security best practices to prevent issues like reentrancy.

2. Testing

Before deploying your contract, it’s crucial to write and execute tests. CosmWasm provides a robust testing framework within Rust to simulate contract behavior and ensure correctness.

Unit Tests

Unit tests validate individual functions within your contract. Use these tests to check that your logic is working as expected for different scenarios, without the need for a full blockchain simulation.

  1. Write unit tests: Add your test functions within the tests module in your contract.

    #[cfg(test)]
    mod tests {
        use super::*;
        // Your test cases here
    }
  2. Test execution: Run your tests using the command:

    cargo test

Integration Testing with Multitest

  1. Set up multitest: Include the cw-multi-test package in your Cargo.toml dependencies.

  2. Simulate complex scenarios: Write tests that involve message execution, querying, and contract-to-contract interactions.

  3. Run multitest: Execute your multitest suite using:

    cargo test --features multitest

Multitest provides a highly realistic environment, simulating actual blockchain behavior without the need for a full node or deployment to a testnet.

3. Test Deployment

After validating your contract through unit and integration tests, the next step is deploying it to a permissionless test environment. Rujira offers two options for deploying your contract for further testing.

  • Localnet / Mocknet: Spin up your own instance and deploy your contract(s) to a local THORChain environment so you can run a simulated THORChain network locally (Midgard, THORNode, mock L1 chains), interact with the chain via CLI and APIs to finally build and test contracts with no reliance on external node operators. See full guide in Local Deployment Guide

To make sure you connect to the right networks, find the overview of connections in API & RPC Endpoints

4. Review & Audit

You can find the full review process under Review and Audit Guide

5. Setup multisig as deployer address

Before you can deploy your audited contracts to mainnet, you will need to deploy a THORChain multisig address that will be used as the deployer address for your smart contracts.

Find out exactly how under Setting Up a THORChain Multisig.

6. Mainnet Deployment

Once your contract has been thoroughly tested, it’s time to deploy it to THORChain mainnet to be live officially on Rujira. This process involves additional security checks and permissions to ensure the integrity of the contract on the network.

See exactly how in Mainnet Deployment Guide

For more details on writing CosmWasm contracts, refer to the official .

For more comprehensive testing, you can use CosmWasm’s framework, which simulates a chain environment in Rust. This allows you to test your contract’s interaction with other contracts and the chain itself.

Stagenet: A permissionless testnet to verify your contract in a real end-to-end environment, but with real money. Contracts will need to be tested thoroughly on Stagenet to showcase compatibility with the network and with connections to existing apps on Rujira. See a general guide on , and do make sure to follow the steps in Stagenet Deployment Guide

To check txs in a block explorer when testing on stagenet, you can find under

All contracts that want to deploy on THORChain and Rujira are subject to an internal review by a core team member and an external review by an auditor. Make sure to follow the for README.md and Cargo.toml.

README.md
RELEASES.md
CosmWasm's setup guide
CosmWasm documentation
Multitest
how to deploy on Stagenet with THORChain's Dev docs
stagenet.thorchain.net
Rujira templates