Skip to main content

Quick Start Guide

Your tools for building and testing smart contracts can work on Bitlayer smoothly as Bitlayer boasting 100% EVM and Ethereum toolchain compatibility.

Note:

We currently support Solidity up to version v0.8.23. Updates for newer versions might be delayed.

Network Configuration

Bitlayer Mainnet

ParameterValue
Network NameBitlayer Mainnet
Chain ID200901
Currency SymbolBTC
Explorerhttps://www.btrscan.com
Public RPC URLshttps://rpc.bitlayer.org, https://rpc.bitlayer-rpc.com, https://rpc.ankr.com/bitlayer
WebSocket
wss://ws.bitlayer.org
wss://ws.bitlayer-rpc.com
Contract AddressesRefer to the Contract Addresses page
Connect WalletClick here to connect your wallet to Bitlayer Mainnet

Introducing Bitlayer Mainnet-V1: Unlocking the Potential of Bitcoin

Click the above link to know more about our Mainnet-V1.

Bitlayer Testnet

ParameterValue
NetworkBitlayer Testnet
Chain ID200810
Currency SymbolBTC
Explorerhttps://testnet-scan.bitlayer.org
Public RPC URLhttps://testnet-rpc.bitlayer.org
WebSocket
wss://testnet-ws.bitlayer.org
wss://testnet-ws.bitlayer-rpc.com
Contract AddressesRefer to the Contract Addresses page
Connect WalletClick here to connect your wallet to Bitlayer Testnet
tip

The "currency symbol" is required by some wallets like MetaMask.

Here are the quick access commands for the Bitlayer Testnet:

Hardhat

Modify your Hardhat config file hardhat.config.ts to point at the Bitlayer Testnet public RPC.

const config: HardhatUserConfig = {
...
networks: {
bitlayer: {
url: "https://testnet-rpc.bitlayer.org" || "",
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
},
};

Foundry

To deploy using the Bitlayer Testnet Public RPC, run:

forge create ... --rpc-url=https://https://testnet-rpc.bitlayer.org/ --legacy

Remix Web IDE

After compiling your contracts, the easiest way to deploy using Remix is by setting up Metamask, then selecting the Bitlayer Testnet network.

In the “Deploy and Run Transactions” tab, use the “Environment” drop-down and select “Injected Provider - MetaMask.”

Connect your wallet and select the Bitlayer Testnet. Your account should be selected automatically in Remix, and you can click “Deploy.”

Truffle

caution

The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog.

Assuming you already have a Truffle environment setup, go to the Truffle configuration file, truffle.js. Make sure to have installed HDWalletProvider: npm install @truffle/hdwallet-provider@1.4.0

const HDWalletProvider = require("@truffle/hdwallet-provider")
...
module.exports = {
networks: {
bitlayer: {
provider: () =>
new HDWalletProvider(process.env.PRIVATE_KEY, "https://testnet-rpc.bitlayer.org"),
network_id: '*',
},
}
}

Brownie

To add the Bitlayer Testnet, run the following command:

brownie networks add Bitlayer host=https://testnet-rpc.bitlayer.org chainid=200810 

To set this as your default network, add the following in your project config file:

networks:
default: bitlayer

Another way to add the Bitlayer Testnet is to create a yaml file and run a command to add it.

This is an example of a yaml file called network-config.yaml

live:
- name: Ethereum
networks:
- chainid: 200810
explorer: https://testnet-scan.bitlayer.org
host: https://testnet-rpc.bitlayer.org
id: bitlayer
name: Bitlayer Testnet

To add the Bitlayer Testnet to the network list, run the following command:

brownie networks import ./network-config.yaml

To deploy on Bitlayer, run the following command. In this example, token.py is the script to deploy the smart contract. Replace this with the name of your script:

brownie run token.py --network Bitlayer

ethers.js

Setting up a Bitlayer Testnet provider in an ethers script:

import { ethers } from "ethers"

const provider = new ethers.providers.JsonRpcProvider("https://testnet-rpc.bitlayer.org")

scaffold-eth

To deploy using Scaffold-eth, you’ll need to point both your Hardhat and React settings at the Bitlayer Testnet.

Configure Hardhat

In the packages/hardhat/hardhat.config.js file, you’ll add the network and select it as the default network.

...
//
// Select the network you want to deploy to here:
//
const defaultNetwork = "Bitlayer";
...
module.exports = {
...
networks: {
...
Bitlayer: {
url: "https://testnet-rpc.bitlayer.org",
accounts: {
mnemonic: mnemonic(),
},
},
}
...
}

Be sure to fund the deployment wallet as well! Run yarn generate to create the wallet and yarn account to check its funds. Once funded, run yarn deploy --network Bitlayer to deploy on the Bitlayer testnet.