Deploy your own Bitcoin dapp
Last updated
Last updated
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.
How to compile smart contracts
How to deploy a contract to Supersonic on both testnet and mainnet
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)
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.
Here are the steps to create new smart contract:
Navigate to the root of your project.
Create a folder named contracts.
Inside the contracts folder, create a file named SimpleStorage.sol.
Now we should add some code to the new SimpleStorage.sol file:
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.
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
Here are the steps to create deploy script with hardhat-zksync-deploy plugin.
Navigate to your project's root directory.
Create a new folder named deploy.
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.