In this quickstart, we'll create a basic Hardhat project.


Before you begin, ensure you:

  1. Fund your wallet with BTC on StratoVM Testnet

Create a Hardhat project

To create an empty Hardhat project:

  1. Create your project directory

mkdir stratovm-tutorial; cd strato-tutorial
  1. Initialize your Node.js project:

npm init
  1. Install Hardhat:

npm install --save-dev hardhat
  1. Initialize the Hardhat project:

npx hardhat init

In the menu that appears, select Create a JavaScript project and press Enter. Accept all the default values in the questionnaire.

You should now have a sample contract that deploys and tests a Lock contract that locks funds for a set time.

Deploy the contract

You can use the public endpoints to deploy your contract to the StratoVM Testnet.

The sample project already includes the deployment script. To deploy on StartoVM, you'll just need to make a few modifications to the hardhat.config.js file:

  1. Create a .env file in the root folder with your wallet's private key and Infura API (if using Infura).

  1. Download and install dotenv

npm i -D dotenv
  1. Add StartoVM to your hardhat.config.js file. The following example shows how to add a public endpoint to the configuration file.

const { PRIVATE_KEY } = process.env;

module.exports = {
  solidity: "0.8.24",
  networks: {
    stratovm_testnet: {
      url: `https://bitcoin-l2-349313-testnet.tc.l2aas.com/rpc`,
      accounts: [PRIVATE_KEY],
  1. Deploy your contract. Replace NETWORK with a relevant network defined in the hardhat.config.js file. For example stratovm_testnet.

npx hardhat ignition deploy ./ignition/modules/Lock.js --network NETWORK

Your output should look something like this:

Deployed Addresses

LockModule#Lock - 0x2c73d6f093A2032D3371bFB9a29f7cE666080c4A

Last updated