Learn

Use

Build

Participate

Learn

Use

Build

Participate

Apr 10, 2025

5 min

Connecting the Hardhat smart contract backend with VeChain's React-based frontend templates

VeChain Official

Building dApps on vechain is easier than ever. on the left is a pc.
Building dApps on vechain is easier than ever. on the left is a pc.
Building dApps on vechain is easier than ever. on the left is a pc.

As part of our efforts to make building on VeChain accessible and easy for absolutely everyone, we'll soon be launching VeChain Builders Academy!

It will contain developer courses, starting simple, and gradually getting more complex with time. Today, we’re sharing here a snippet to make sure all budding VeChain Builders are now equipped not only to deploy smart contracts on VeChain but also to quickly connect them to a production-ready frontend. This article will show you how to use your Hardhat smart contract as a backend and integrate it with VeChain's React-based front-end templates - the fastest way to launch your first dApp on VeChain.

If you're familiar with Ethereum development, you'll feel right at home - but with VeChain, you get more than just compatibility. The combination of VeChain's EVM support, optimized tooling, and pre-made templates allows you to move from a deployed smart contract to a fully functional dApp faster than ever, without compromising on scalability or UX.

Step 1 — Treating Hardhat as Your Backend

When you deploy your smart contract using Hardhat on VeChain's Testnet, Solo node, or Mainnet, you are essentially building the backend logic of your decentralized application. Unlike traditional web apps where the backend is a server or cloud function, in blockchain applications, the smart contract itself serves as the backend. This means all core operations happen directly on-chain without intermediaries.

The smart contract is responsible for:

  • On-Chain Storage

  • Payment Handling

  • Data Access

  • Permission Control

What You Get After Deployment

Once deployed, the contract will generate two essential components:

Contract Address

 The unique address of your smart contract on the blockchain. This is where users will interact when sending tips or reading data.

ABI (Application Binary Interface)

 A JSON description of your contract's methods and events. The ABI acts as a “menu” allowing your front-end to understand how to communicate with the contract - how to call functions, send transactions, and listen to events.

These two elements are the only things you need to fully connect your front end to the deployed contract. From this point, your React app (or any front-end framework) can interact with the VeChainThor blockchain by invoking methods defined in the ABI, sending VET tips, reading supporter messages, and displaying live on-chain data.

Step 2 – Connecting Your Front-End to the Smart Contract

Once your front-end project is ready, the next step is connecting it to your deployed contract using the VeChain SDK.

VeChain is EVM-compatible, but it has its own transaction structure, dual-token model (VET + VTHO), and features like fee delegation. That’s why it’s important to use the official SDK, which fully supports these features out of the box.

We’ll use @vechain/sdk-network and @vechain/sdk-core to load and interact with the contract directly.

✅ Installation

npm install @vechain/sdk-core @vechain/sdk-network

✅ Contract Setup Example

import { ThorClient } from '@vechain/sdk-network'

import { ABIContract, Address } from '@vechain/sdk-core'

const thorClient = ThorClient.at('https://testnet.vechain.org')

const contract = thorClient.contracts.load(

Address.of('<YOUR_DEPLOYED_CONTRACT_ADDRESS>'),

  ABIContract.ofAbi(<YOUR_ABI_OBJECT>) // Not a path — pass the ABI object itself

)

Make sure to replace <YOUR_DEPLOYED_CONTRACT_ADDRESS> with the actual contract address as a string.  This is the same approach used in the official Buy Me a Coffee example. We recommend checking it out if you want a complete working reference.

Now, your front end can make calls and send transactions using VeChain-native methods, with full support for gas fees, fee delegation, and transaction visibility.

  • Use the contract instance to:

  • Send transactions (e.g., buy a coffee)

  • Fetch data (e.g., list all coffees)

  • Allow the owner to withdraw funds

Step 3 - Customize, Extend, and Launch

You can now:

  • Customize the front-end with your brand

  • Extend functionality with other VeChain services, such as VeBetterDAO or VeCarbon

  • Deploy your dApp using VeChain's public RPC endpoints for Testnet or Mainnet

If this snippet piqued your curiosity, there’s a full, free course coming up soon!



As part of our efforts to make building on VeChain accessible and easy for absolutely everyone, we'll soon be launching VeChain Builders Academy!

It will contain developer courses, starting simple, and gradually getting more complex with time. Today, we’re sharing here a snippet to make sure all budding VeChain Builders are now equipped not only to deploy smart contracts on VeChain but also to quickly connect them to a production-ready frontend. This article will show you how to use your Hardhat smart contract as a backend and integrate it with VeChain's React-based front-end templates - the fastest way to launch your first dApp on VeChain.

If you're familiar with Ethereum development, you'll feel right at home - but with VeChain, you get more than just compatibility. The combination of VeChain's EVM support, optimized tooling, and pre-made templates allows you to move from a deployed smart contract to a fully functional dApp faster than ever, without compromising on scalability or UX.

Step 1 — Treating Hardhat as Your Backend

When you deploy your smart contract using Hardhat on VeChain's Testnet, Solo node, or Mainnet, you are essentially building the backend logic of your decentralized application. Unlike traditional web apps where the backend is a server or cloud function, in blockchain applications, the smart contract itself serves as the backend. This means all core operations happen directly on-chain without intermediaries.

The smart contract is responsible for:

  • On-Chain Storage

  • Payment Handling

  • Data Access

  • Permission Control

What You Get After Deployment

Once deployed, the contract will generate two essential components:

Contract Address

 The unique address of your smart contract on the blockchain. This is where users will interact when sending tips or reading data.

ABI (Application Binary Interface)

 A JSON description of your contract's methods and events. The ABI acts as a “menu” allowing your front-end to understand how to communicate with the contract - how to call functions, send transactions, and listen to events.

These two elements are the only things you need to fully connect your front end to the deployed contract. From this point, your React app (or any front-end framework) can interact with the VeChainThor blockchain by invoking methods defined in the ABI, sending VET tips, reading supporter messages, and displaying live on-chain data.

Step 2 – Connecting Your Front-End to the Smart Contract

Once your front-end project is ready, the next step is connecting it to your deployed contract using the VeChain SDK.

VeChain is EVM-compatible, but it has its own transaction structure, dual-token model (VET + VTHO), and features like fee delegation. That’s why it’s important to use the official SDK, which fully supports these features out of the box.

We’ll use @vechain/sdk-network and @vechain/sdk-core to load and interact with the contract directly.

✅ Installation

npm install @vechain/sdk-core @vechain/sdk-network

✅ Contract Setup Example

import { ThorClient } from '@vechain/sdk-network'

import { ABIContract, Address } from '@vechain/sdk-core'

const thorClient = ThorClient.at('https://testnet.vechain.org')

const contract = thorClient.contracts.load(

Address.of('<YOUR_DEPLOYED_CONTRACT_ADDRESS>'),

  ABIContract.ofAbi(<YOUR_ABI_OBJECT>) // Not a path — pass the ABI object itself

)

Make sure to replace <YOUR_DEPLOYED_CONTRACT_ADDRESS> with the actual contract address as a string.  This is the same approach used in the official Buy Me a Coffee example. We recommend checking it out if you want a complete working reference.

Now, your front end can make calls and send transactions using VeChain-native methods, with full support for gas fees, fee delegation, and transaction visibility.

  • Use the contract instance to:

  • Send transactions (e.g., buy a coffee)

  • Fetch data (e.g., list all coffees)

  • Allow the owner to withdraw funds

Step 3 - Customize, Extend, and Launch

You can now:

  • Customize the front-end with your brand

  • Extend functionality with other VeChain services, such as VeBetterDAO or VeCarbon

  • Deploy your dApp using VeChain's public RPC endpoints for Testnet or Mainnet

If this snippet piqued your curiosity, there’s a full, free course coming up soon!