Building with Solidity

Compile and Deploy Contracts

Learn how to compile Solidity with solc (produce bytecode + ABI) and deploy to VeChainThor using Hardhat and the VeChain SDK. We’ll cover what compilation outputs, a simple deploy workflow, and assumptions for non-upgradeable contracts.

Compiling Smart Contracts

Smart contracts must be compiled into bytecode before they can be deployed to the VeChain blockchain. In this lesson, you’ll learn how to compile and deploy Solidity contracts using the recommended toolchain for VeChain development.

We’ll cover:

  • How to compile contracts with solc

  • What happens during compilation

  • A quick overview of deploying with Hardhat (with external link to the full tutorial)

Solc – The Solidity Compiler

The preferred method for compiling smart contracts on VeChain is using the official Solidity Complier (solc), the official Solidity compiler.

🔹 What is solc?

solc (Solidity Compiler) turns your .sol source code into bytecode and ABI (Application Binary Interface), which are required to deploy and interact with your contract on-chain.

🔹 How to Install

We recommend installing via npm or brew.

brew install solidity

Make sure you're using Solidity version ^0.8.x as specified in your contract.

Navigate to the directory that hosts your contract. Then:

solc Learn2Earn.sol \                                   
  --evm-version shanghai \
  --optimize --optimize-runs 200 \
  --bin --bin-runtime \
  --abi --hashes \
  --metadata --asm \
  --overwrite -o out

What Happens When You Compile?

Compiling your contract does two things:

  1. Generates bytecode – the low-level code that gets deployed to the blockchain.

  2. Generates the ABI – a JSON interface that tells frontends and tools how to interact with your contract.

  3. Example output:

WorkshopContract.json
├── abi
├── bytecode

You can then use these artifacts to:

  • Deploy via a frontend or script

  • Interact via VeChain Inspector

  • Run automated tests

Deployment Tools

Once compiled, your contract can be deployed using various tools. On VeChain, you can use Hardhat to deploy your contracts.

Hardhat is a powerful developer framework for testing, compiling, and deploying smart contracts.

Use Hardhat to manage your Solidity contracts. For VeChain deployments, interact using VeChain’s official SDKs such as @vechain/sdk-network, or using tools like VeChain Inspector.

Non-Upgradeable Contracts

The contracts you’re writing now are non-upgradeable. This means:

  • Their logic is fixed once deployed

  • They’re simple, fast, and low-cost

Ideal for workshops and learning environments