Get Bitcoin Balance with Remix
Last updated
Was this helpful?
Last updated
Was this helpful?
In this section, we’ll deploy a small contract in with a single method which calls the Bitcoin Balance precompile and returns the balance as a uint256.
We recommend you use Solidity version 0.8.25 or later, but previous versions are also expected to work.
To follow along, you’ll need:
Metamask (or another Remix-supported web wallet) connected to Hemi testnet as a custom network;
A nonzero ETH balance tunneled over to a Hemi address in your wallet you want to deploy the demo contract with to pay deployment gas fees.
To start, open Remix, delete any existing contracts in the “contracts” folder,.
Create a new contract file, which for our example we’ll call “BitcoinBalDemo.sol”.
Paste in the following code:
You can now compile and deploy this contract, and try out calling it with a Bitcoin address string to see the address's balance (in satoshis) returned by hVM.