Deploy your own Bitcoin dapp

Extend your Bitcoin app with more dapps

If you’ve built dapps on Ethereum, you can easily build on Bitcoin. Your Bitcoin chain is EVM-equivalent, allowing you to write Solidity smart contracts on Bitcoin without learning a new toolkit. All your existing code and tools work seamlessly out of the box.

What you'll learn

  • How to compile smart contracts

  • How to deploy a contract to Supersonic on both testnet and mainnet

Prerequisites

  • A Node.js installation running at minimum Node.js version 14.

  • Initialized Hardhat TypeScript project

  • A wallet with sufficient BVM on Supersonic to pay for deploying smart contracts.

    • For testnet, you can get BVM from the faucet.

    • For mainnet, you can buy BVM from Uniswap and use Naka bridge to bridge funds to Supersonic.

This how-to guide explains how to deploy a smart contract on Supersonic using hardhat-zksync-deploy (note: Supersonic is deployed on Bitcoin using ZK Stack so we could reuse ZKSync's developer suite for deploying contracts)

Installation

To install the hardhat-zksync-deploy plugin and additional necessary packages, execute the following command:

Once installed, add the plugin at the top of the hardhat.config.ts file.

Create a new smart contract

Here are the steps to create new smart contract:

  1. Navigate to the root of your project.

  2. Create a folder named contracts.

  3. Inside the contracts folder, create a file named SimpleStorage.sol.

Now we should add some code to the new SimpleStorage.sol file:

Configuration

Before we continue with the deployment, we must include hardhat-zksync-solc plugin in order to compile our contracts.

Add the plugin at the top of the hardhat.config.ts file:

To enable deployment across various networks within the hardhat.config.ts file, it's essential to configure the networks section. For this example, we will be deploying on Supersonic Testnet & Mainnet, so we need to adjust network accordingly. Furthermore, it's also important to configure the compilers settings.

Compilation

Execute the following command in your terminal to run the compilation:

After successful compilation, you should see the output similar to this:

In the root of your project you will see two new folders that represent zksolc compilation result:

  • artifacts-zk

  • cache-zk

Deploy script

Here are the steps to create deploy script with hardhat-zksync-deploy plugin.

  1. Navigate to your project's root directory.

  2. Create a new folder named deploy.

  3. Inside the deploy folder, create a file named deploy-simple-storage.ts.

Now we should add some code to the new deploy-simple-storage.ts file:

To deploy contract on Supersonic Testnet, run the following command:

To deploy contract on Supersonic Mainnet, run the command:

After successful deployment, your console output should look something like this:

Check your deployed contract on this block explorer for Supersonic Testnet or on this block explorer for Supersonic Mainnet using deployed address of the contract.

Last updated