bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 13쪽 중 11쪽
# Output
Represents a Bitcoin transaction output.
```
struct Output {
uint256 outValue; // Value of the output in satoshis
bytes script; // Output script
string outputAddress; // Output address
bool isOpReturn; // Indicates if the output is an OP_RETURN output
bytes opReturnData; // Data contained in the OP_RETURN output
bool isSpent; // Indicates if the output is spent
uint256 fullScriptLength; // Full length of the output script
bool containsFullScript; // Indicates if the full output script is contained
SpentDetail spentDetail; // Details of the spent output
}
```
***
#### SpentDetail
Represents details of a spent output.
```
struct SpentDetail {
bytes32 spendingTxId; // Transaction ID of the spending transaction
uint256 inputIndex; // Index of the input in the spending transaction
}
```
***
#### BitcoinHeader
Represents a Bitcoin block header.
```
struct BitcoinHeader {
uint32 height; // Block height
bytes32 blockHash; // Block hash
uint32 version; // Version
bytes32 previousBlockHash; // Previous block hash
bytes32 merkleRoot; // Merkle root
uint32 timestamp; // Timestamp
uint32 bits; // Bits
uint32 nonce; // Nonce
}
```
***
## 🧑💻 IBitcoinKit Interface
The `IBitcoinKit` interface defines the methods available for interacting with the BitcoinKit contract.
```
interface IBitcoinKit {
function getUTXOsForBitcoinAddress(string calldata btcAddress, uint256 pageNumber, uint256 pageSize) external view returns (UTXO[] memory);
function getTxConfirmations(bytes32 txId) external view returns (uint32 confirmations);
function getBitcoinAddressBalance(string calldata btcAddress) external view returns (uint256 balance);
function getTransactionByTxId(bytes32 txId) external view returns (Transaction memory);
function getTransactionInputsByTxId(bytes32 txId) external view returns (Input[] memory);
function getTransactionOutputsByTxId(bytes32 txId) external view returns (Output[] memory);
function getLastHeader() external view returns (BitcoinHeader memory);
function getHeaderN(uint32 height) external view returns (BitcoinHeader memory);
}
```
***
#### getBitcoinAddressBalance
Retrieves the balance of a given Bitcoin address.
Precompile Address: 0x40
```
function getBitcoinAddressBalance(string calldata btcAddress) public view returns (uint256 balance)
```
***
#### getUTXOsForBitcoinAddress
Precompile Address: 0x41
Retrieves UTXOs for a given Bitcoin address, page number, and page size.
```
function getUTXOsForBitcoinAddress(string calldata btcAddress, uint256 pageNumber, uint256 pageSize) public view returns (UTXO[] memory)
```
***
#### getTransactionByTxId
Retrieves UTXOs for a given Bitcoin address, page number, and page size.
Precompile Address: 0x42
```
function getTransactionByTxId(bytes32 txId) external view returns (Transaction memory);
```
***
#### getTxConfirmations
Retrieves the number of confirmations for a given transaction ID.
Precompile Address: 0x43
```
function getTxConfirmations(bytes32 txId) public view returns (uint32 confirmations)
```
***
#### getLastHeader
Retrieves the latest Bitcoin block header.
Precompile Address: 0x44
```
function getLastHeader() public view returns (BitcoinHeader memory)
```
***
#### getHeaderN
Precompile Address: 0x45
Retrieves the Bitcoin block header at a specific height.
```
function getHeaderN(uint32 height) public view returns (BitcoinHeader memory)
```
***
# viem
## 🌐 **Overview**
[viem ](https://viem.sh/)extension for [Hemi](https://hemi.xyz/). 
It includes: 
* Chain definitions!
* [Bitcoin finality](https://docs.hemi.xyz/foundational-topics/pop-consensus-and-bitcoin-finality) helper!
* [Bitcoin Kit](https://github.com/hemilabs/research/blob/main/research/Bitcoin-kit.md) wrappers!
***
## 📚 Tutorial
1. [Installation ](https://github.com/hemilabs/hemi-viem#installation)
2. [Example](https://github.com/hemilabs/hemi-viem#example)
# Contract Addresses
{% hint style="info" %}
### 📜 **TL;DR:**
* In this article, you’ll find useful contract addresses for Hemi Mainnet, Hemi Sepolia, and commonly used protocols.
{% endhint %}
***
## Hemi Mainnet
### L1 Hemi Contracts
Core Hemi contracts deployed on **Ethereum Mainnet**.
<table><thead><tr><th width="324">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>AddressManager</code></td><td><code>0xA5F37791378c55941a52B4dCb70Be4D8D09f5e43</code></td></tr><tr><td><code>AnchorStateRegistryProxy</code></td><td><code>0xF44007EAF2faFdD8bA8d3551F23CD2b879F54677</code></td></tr><tr><td><code>DelayedWETHProxy</code></td><td><code>0xc5627348Dbc9179cFb5a24C8199635770Ea575A3</code></td></tr><tr><td><code>DisputeGameFactoryProxy</code></td><td><code>0x5442d0ddB33B396879D2d016A9ad09ad122562C3</code></td></tr><tr><td><code>L1CrossDomainMessengerProxy</code></td><td><code>0xF005dFb08377faD44588Af68d0884D272A6fb050</code></td></tr><tr><td><code>L1ERC721BridgeProxy</code></td><td><code>0xa446331bD28cbe0186A983a27C528f566B6bedE0</code></td></tr><tr><td><code>L1StandardBridgeProxy</code></td><td><code>0x5eaa10F99e7e6D177eF9F74E519E319aa49f191e</code></td></tr><tr><td><code>L2OutputOracleProxy</code></td><td><code>0x6daF3a3497D8abdFE12915aDD9829f83A79C0d51</code></td></tr><tr><td><code>Mips</code></td><td><code>0x42Ff661af011939f699D67bd021d237eBcBA9c2A</code></td></tr><tr><td><code>OptimismMintableERC20FactoryProxy</code></td><td><code>0x0262fEDC4A98f94dDB90CeF0E058644d8409342C</code></td></tr><tr><td><code>OptimismPortalProxy</code></td><td><code>0x39a0005415256B9863aFE2d55Edcf75ECc3A4D7e</code></td></tr><tr><td><code>OptimismPortal2</code></td><td><code>0x04dcfE50e43823A1D8f6e3Fbb8af10BfB7Ebb634</code></td></tr><tr><td><code>PreimageOracle</code></td><td><code>0x613F36BE58Ba712B37474F4B82484D680D24ed20</code></td></tr><tr><td><code>ProtocolVersionsProxy</code></td><td><code>0x13Cb1B6e69Ec8fF6a5C8823d1e8dc78CCCf3Ce48</code></td></tr><tr><td><code>ProxyAdmin</code></td><td><code>0xbE81A9D662422f667F634f3Fc301e2E360FeFB30</code></td></tr><tr><td><code>SafeProxyFactory</code></td><td><code>0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2</code></td></tr><tr><td><code>SafeSingleton</code></td><td><code>0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552</code></td></tr><tr><td><code>SuperchainConfigProxy</code></td><td><code>0x15144FB8621cB3c4ED3DB223c173ffb58C8D2aB8</code></td></tr><tr><td><code>SystemConfigProxy</code></td><td><code>0x5ae68684D9179A8053883f1Df599Ea7Fb35303c3</code></td></tr><tr><td><code>SystemOwnerSafe</code></td><td><code>0x8434dc705e4B729405Dd66C94DfC62bc3825Ea69</code></td></tr></tbody></table>
***
### L2 Hemi Contracts
Core Hemi contracts deployed on **Hemi**.
<table><thead><tr><th width="285">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>WETH9</code></td><td><a href="https://explorer.hemi.xyz/token/0x4200000000000000000000000000000000000006"><code>0x4200000000000000000000000000000000000006</code></a></td></tr><tr><td><code>OptimismMintableERC20Factory</code></td><td><a href="https://explorer.hemi.xyz/address/0x4200000000000000000000000000000000000012"><code>0x4200000000000000000000000000000000000012</code></a></td></tr><tr><td><code>OptimismMintableERC721Factory</code></td><td><a href="https://explorer.hemi.xyz/address/0x4200000000000000000000000000000000000017"><code>0x4200000000000000000000000000000000000017</code></a></td></tr><tr><td><code>L2StandardBridge</code></td><td><a href="https://explorer.hemi.xyz/address/0x4200000000000000000000000000000000000010"><code>0x4200000000000000000000000000000000000010</code></a></td></tr><tr><td><code>L2ERC721Bridge</code></td><td><code>0x4200000000000000000000000000000000000014</code></td></tr></tbody></table>
***
### Utilities Contracts
Commonly used utility contracts deployed on **Hemi**.
<table><thead><tr><th width="247">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>BitcoinKit v1</code></td><td>0x7007dd1C09527B92AEcd8Ae6570B73d09E0B8F12</td></tr></tbody></table>
***
### hVM Precompiles
For hVM precompile contract addresses, visit the [hVM Feature Summary](/building-bitcoin-apps/hemi-virtual-machine-hvm/feature-summary).
***
### Token Contracts
For a list of all token contract addresses deployed on **Hemi,** visit [`hemilabs/token-list`](https://github.com/hemilabs/token-list/blob/master/src/hemi.tokenlist.json) .
***
## Hemi Sepolia
### L1 Hemi Contracts
Core Hemi contracts deployed on **Sepolia**.
<table><thead><tr><th width="289">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>AddressManager</code></td><td><a href="https://sepolia.etherscan.io/address/0x23f0022354241fdb721dc43e7897d7af662a2995"><code>0x23f0022354241FDb721Dc43E7897d7Af662A2995</code></a></td></tr><tr><td><code>L1CrossDomainMessengerProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0x9bcccf1d222539c4c47e4c6f5749e4d5fa33215c"><code>0x9bCCCf1d222539c4C47E4C6f5749e4d5fA33215c</code></a></td></tr><tr><td><code>L2OutputOracleProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0x032d1e1dd960a4b027a9a35ff8b2b672e333bc27"><code>0x032d1e1dd960A4B027a9a35FF8B2b672E333Bc27</code></a></td></tr><tr><td><code>OptimismPortalProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xB6f9579980aE46f61217A99145645341E49E2516"><code>0xB6f9579980aE46f61217A99145645341E49E2516</code></a></td></tr><tr><td><code>ProtocolVersionsProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xBD869d97B85C450d396215c5E1a81bbFA4545e23"><code>0xBD869d97B85C450d396215c5E1a81bbFA4545e23</code></a></td></tr><tr><td><code>DisputeGameFactoryProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0x4cb8fdc8E1A8Ad01369F9a159C67c8be794a98FA"><code>0x4cb8fdc8E1A8Ad01369F9a159C67c8be794a98FA</code></a></td></tr><tr><td><code>L1StandardBridgeProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xc94b1bee63a3e101fe5f71c80f912b4f4b055925"><code>0xc94b1BEe63A3e101FE5F71C80F912b4F4b055925</code></a></td></tr><tr><td><code>OptimismMintableERC20FactoryProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xb4bCe3efD3282Da4eEC69429966a85f92298799B"><code>0xb4bCe3efD3282Da4eEC69429966a85f92298799B</code></a></td></tr><tr><td><code>ProxyAdmin</code></td><td><a href="https://sepolia.etherscan.io/address/0xc43ED1E8D70d0e5801514833fAD3D93Ba16Da4Aa"><code>0xc43ED1E8D70d0e5801514833fAD3D93Ba16Da4Aa</code></a></td></tr><tr><td><code>L1StandardBridgeProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xc94b1BEe63A3e101FE5F71C80F912b4F4b055925"><code>0xc94b1BEe63A3e101FE5F71C80F912b4F4b055925</code></a></td></tr><tr><td><code>L1ERC721BridgeProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xa5ba2558b41f34f0b5cc4ed389386201a3d31aec"><code>0xa5ba2558B41F34f0B5Cc4eD389386201a3D31AEc</code></a></td></tr><tr><td><code>SystemConfigProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xfa73580F4D72294Ae9EE3DAaC36D8bF111B37Ce9"><code>0xfa73580F4D72294Ae9EE3DAaC36D8bF111B37Ce9</code></a></td></tr></tbody></table>
***
### L2 Hemi Contracts
Core Hemi contracts deployed on **Hemi Sepolia**.
<table><thead><tr><th width="301">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>L2ToL1MessagePasser</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000016"><code>0x4200000000000000000000000000000000000016</code></a></td></tr><tr><td><code>L2CrossDomainMessenger</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000007"><code>0x4200000000000000000000000000000000000007</code></a></td></tr><tr><td><code>L2StandardBridge</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000010"><code>0x4200000000000000000000000000000000000010</code></a></td></tr><tr><td><code>L2ERC721Bridge</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000014"><code>0x4200000000000000000000000000000000000014</code></a></td></tr><tr><td><code>SequencerFeeVault</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000011"><code>0x4200000000000000000000000000000000000011</code></a></td></tr><tr><td><code>OptimismMintableERC20Factory</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000012"><code>0x4200000000000000000000000000000000000012</code></a></td></tr><tr><td><code>OptimismMintableERC721Factory</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000017"><code>0x4200000000000000000000000000000000000017</code></a></td></tr><tr><td><code>L1Block</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000015"><code>0x4200000000000000000000000000000000000015</code></a></td></tr><tr><td><code>GasPriceOracle</code></td><td><a href="https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000F"><code>0x420000000000000000000000000000000000000F</code></a></td></tr><tr><td><code>ProxyAdmin</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000018"><code>0x4200000000000000000000000000000000000018</code></a></td></tr><tr><td><code>BaseFeeVault</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000019"><code>0x4200000000000000000000000000000000000019</code></a></td></tr><tr><td><code>L1FeeVault</code></td><td><a href="https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000001A"><code>0x420000000000000000000000000000000000001A</code></a></td></tr><tr><td><code>GovernanceToken</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000042"><code>0x4200000000000000000000000000000000000042</code></a></td></tr><tr><td><code>SchemaRegistry</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000020"><code>0x4200000000000000000000000000000000000020</code></a></td></tr><tr><td><code>EAS</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000021"><code>0x4200000000000000000000000000000000000021</code></a></td></tr></tbody></table>
***
### Utilities Contracts
Commonly used utility contracts deployed on **Hemi Sepolia**.
<table><thead><tr><th width="247">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>BitcoinKit v0</code></td><td><a href="https://testnet.explorer.hemi.xyz/address/0xeC9fa5daC1118963933e1A675a4EEA0009b7f215?tab=read_contract"><code>0xeC9fa5daC1118963933e1A675a4EEA0009b7f215</code></a></td></tr></tbody></table>
***
### hVM Precompiles
For hVM precompile contract addresses, visit the [hVM Feature Summary](/building-bitcoin-apps/hemi-virtual-machine-hvm/feature-summary).
***
### Token Contracts
For a list of all token contract addresses deployed on **Hemi Sepolia,** visit [`hemilabs/token-list`](https://github.com/hemilabs/token-list/blob/master/src/hemi.tokenlist.json) .
# Contract Verification
{% hint style="info" %}
## 📜 **TL;DR:**
This guide explains how to verify smart contracts deployed on the Hemi blockchain using two methods:
1. Manual UI-based verification via Blockscout.
2. API-based verification using Hardhat.
{% endhint %}
***
## 🏁 Prerequisites
* Hemi RPC URL and deployed contract address.
* Contract source code available (flattened only if verifying manually via the Hemi Blockscout UI).
***
## 🖥️ Blockscout UI Verification 
{% hint style="info" %}
Manual verification is performed directly through the Blockscout UI. This method requires flattening the contract source code and uploading it manually.
{% endhint %}
#### 1. Flatten the contract
Flattening a contract is necessary when verifying through the UI. 
**For Hardhat:**
```
npx hardhat flatten contracts/MyContract.sol > MyContractFlattened.sol
```
**For Foundry:**
```
forge flatten src/MyContract.sol > MyContractFlattened.sol
```
***
#### 2. Access Hemi Blockscout
Go to Hemi Blockscout Explorer and navigate to the [Verify & Publish Contract](https://testnet.explorer.hemi.xyz/contract-verification) page.
***
#### 3. Input contract information
* `Smart contract / Address`: Paste the address that your smart contract was deployed to.
* `Contract license`: Select 'No License' unless otherwise specified.
* `Verification method`: Choose Solidity (Flattened source code).
* `Is Yul contract`: Leave unchecked unless your contract is written in Yul.
* `Include nightly builds`: Select only if required.
* `Compiler`: Choose the exact version specified in `pragma solidity X.X.X` in your code.
* `EVM Version`: Set to default unless you used a specific EVM version.
* `Optimization enabled`: Deselect optimization.
Copy and paste the entire flattened contract code into the Contract code field and click 'Verify & publish'.
<figure><img src="https://3063395300-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBrGAUP9hcnvqWQvHZlN0%2Fuploads%2FAtxZLDxIkKZPLzIipL7U%2Fimage.png?alt=media&token=cf70463a-c78c-42c5-ae14-149788a659c6" alt=""><figcaption></figcaption></figure>
***
#### 4. Submit for verification 🎉
Once all required details are entered, submit the form. BlockScout will compare the uploaded source code with the deployed bytecode. If they match, your contract will be verified.
{% hint style="success" %}
To confirm verification, search for your contract address on BlockScout. A green check mark next to your contract indicates successful verification.
{% endhint %}
<figure><img src="https://3063395300-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBrGAUP9hcnvqWQvHZlN0%2Fuploads%2FrMKtpOQI9OvCoLveXEnw%2Fimage.png?alt=media&token=18c636a4-d889-4de4-a235-0d97d4845563" alt="" width="375"><figcaption></figcaption></figure>
***
## 🚧 Hardhat Verification
#### 1. Install dependencies
If you haven't already installed Hardhat and the verification plugin (adapted for Blockscout), run the following:
```
npm install --save-dev hardhat @nomiclabs/hardhat-etherscan @nomicfoundation/hardhat-verify
```
***
#### 2. Configure Hardhat for Hemi
In your \``hardhat.config.js`\`, set up the Hemi network and include Blockscout API information for contract verification:
```javascript
require('dotenv').config()
require("@nomiclabs/hardhat-ethers");
require("@nomicfoundation/hardhat-verify");
module.exports = {
solidity: "0.8.20",
networks: {
hemi: {
url: "https://rpc.hemi.network/rpc",
chainId: 43111,
accounts: [`0x${process.env.PRIVATE_KEY}`],
},
},
etherscan: {
apiKey: {
// Is not required by blockscout. Can be any non-empty string
'hemi-mainnet': "abc"
},
customChains: [
{
network: "hemi-mainnet",
chainId: 43111,
urls: {
apiURL: "https://explorer.hemi.xyz/api",
browserURL: "https://explorer.hemi.xyz",
}
}
]
},
sourcify: {
enabled: false
}
};
```
***
#### 3. Verify the contract
Once deployed, you can verify the contract using Hardhat’s \``verify`\` command. Make sure to include any constructor arguments if necessary:
```
npx hardhat verify --network hemi <DEPLOYED_CONTRACT_ADDRESS> "Constructor Argument 1" "Constructor Argument 2"
```
***
#### 4. Verification successful! 🎉
{% hint style="warning" %}
If you encounter the following error, visit the [Hemi Block Explorer](https://testnet.explorer.hemi.xyz) and search your contract address to confirm verification:
{% endhint %}
```
hardhat-verify found one or more errors during the verification process:
Etherscan:
The block explorer's API responded that the contract contracts/MyToken.sol:MyToken at <CONTRACT ADDRESS> is already verified.
This can happen if you used the '--force' flag. However, re-verification of contracts might not be supported
by the explorer (e.g., Ether프로젝트로 돌아가기