Files
smom-dbis-138/docs/04-configuration/CRONOS_EXPLORER_OPERATIONS.md

131 lines
5.3 KiB
Markdown
Raw Normal View History

# Cronos Explorer Operations
Reference for Cronos Explorer API, contract verification, and deployment confirmation based on [official Cronos docs](https://docs.cronos.org/).
---
## Overview
| Resource | URL |
|----------|-----|
| **Explorer** | https://explorer.cronos.org |
| **API Docs** | https://explorer-api-doc.cronos.org/mainnet |
| **API Base** | https://explorer-api.cronos.org/mainnet/api |
| **Contract Verification** | https://explorer.cronos.org/verifyContract |
---
## API Key (CRONOSCAN_API_KEY)
- **Source**: [explorer.cronos.org/register](https://explorer.cronos.org/register)
- **Usage**: `?apikey={key}` on API requests
- **Rate limits**: Higher with key (see [Block Explorer and API Keys](https://docs.cronos.org/block-explorers/block-explorer-and-api-keys))
- **Account dashboard**: View API keys, contract verification status
---
## API Format
Per [Cronos docs](https://docs.cronos.org/block-explorers/block-explorer-and-api-keys#5-using-apis):
```
GET https://explorer-api.cronos.org/mainnet/api/v1/{module}/{action}?apikey={key}
```
**Working endpoint (tested):**
- `api/v1/ethproxy/getBlockNumber` — returns current block
**Blockscout-style** (`?module=X&action=Y`) is documented at [cronos.org/explorer/api-docs](https://cronos.org/explorer/api-docs). Forge `verify-contract --verifier blockscout` is incompatible (Cronos API path/format differs). Use manual verification at explorer.cronos.org/verifyContract.
---
## Contract Verification
Per [Contract Deployment and Verification](https://docs.cronos.org/for-dapp-developers/cronos-smart-contract/contract-verification):
### 1. Web interface (recommended for Foundry users)
- **Mainnet**: https://explorer.cronos.org/verifyContract
- **Testnet**: https://explorer.cronos.org/testnet/verifyContract
### 2. Programmatic (Hardhat)
- Cronos supports Hardhat out of the box
- See [cronos-hardhat-boilerplate](https://github.com/kentimsit/cronos-hardhat-boilerplate)
- Requires API key in Hardhat config
### 3. Foundry
- `forge verify-contract --verifier blockscout` fails (Cronos Explorer API format differs)
- Run `./scripts/deployment/verify-cronos-contracts.sh` to attempt; falls back to manual verification
- **Recommended**: Manual verification via the web interface above
---
## Deployed Contracts (Cronos Chain 25)
| Contract | Address |
|----------|---------|
| WETH9 | `0x99B3511A2d315A497C8112C1fdd8D508d4B1E506` |
| WETH10 | `0x3304b747E565a97ec8AC220b0B6A1f6ffDB837e6` |
| CCIPWETH9Bridge | `0x3Cc23d086fCcbAe1e5f3FE2bA4A263E1D27d8Cab` |
| CCIPWETH10Bridge | `0x105F8A15b819948a89153505762444Ee9f324684` |
---
## Confirmation Tasks
### On-chain confirmation (RPC)
Use `eth_getCode` to confirm contracts have bytecode:
```bash
RPC="https://evm.cronos.org"
for addr in 0x99B3511A2d315A497C8112C1fdd8D508d4B1E506 0x3304b747E565a97ec8AC220b0B6A1f6ffDB837e6 0x3Cc23d086fCcbAe1e5f3FE2bA4A263E1D27d8Cab 0x105F8A15b819948a89153505762444Ee9f324684; do
code=$(cast code $addr --rpc-url $RPC 2>/dev/null)
echo "$addr: $([ ${#code} -gt 10 ] && echo 'OK' || echo 'MISSING')"
done
```
### API confirmation
```bash
./scripts/deployment/check-cronos-api.sh # Tests CRONOSCAN_API_KEY, block number
```
### Manual verification
1. Run `./scripts/deployment/export-cronos-verification-sources.sh` to generate flattened sources in `.cronos-verify/`
2. Follow the step-by-step runbook: `docs/deployment/CRONOS_VERIFICATION_RUNBOOK.md`
3. Check status: `./scripts/deployment/check-cronos-verification-status.sh`
4. Or: Open https://explorer.cronos.org/verifyContract, enter address, select compiler/optimization, paste flattened source
5. If the API returns `Invalid parameter(s)` or `JSON files not found`, prefer the web UI and upload the generated `*_standard_input.json` file instead of retrying the API blindly.
---
## Cronos Explorer API Operations (per cronos.org/explorer/api-docs)
The Blockscout-style API supports:
| Module | Actions | Description |
|--------|---------|-------------|
| **account** | balance, balancemulti, txlist, txlistinternal, tokentx, tokenbalance, tokenlist, getminedblocks, listaccounts, eth_get_balance, pendingtxlist | Account balances, transactions |
| **logs** | getLogs | Event logs |
| **token** | getToken, getTokenHolders | ERC-20/721 info |
| **stats** | tokensupply, ethsupply, ethsupplyexchange, coinsupply, coinprice, totalfees | Supply and price |
| **block** | getblockreward, getblocknobytime, eth_block_number | Block data |
| **contract** | getsourcecode, getabi ( Blockscout) | Contract source/ABI |
*Note: Actual base URL for module/action format on Cronos may differ; `explorer.cronos.org/api` returns HTML. Use RPC for reliable on-chain checks.*
---
## Related Scripts
- `scripts/deployment/check-cronos-api.sh` — Test API key, block number, list deployed addresses
- `scripts/deployment/export-cronos-verification-sources.sh` — Export flattened source for manual verification
- `scripts/deployment/check-cronos-verification-status.sh` — Check deployment status and verification links
- `scripts/deployment/verify-deployed-contracts.sh` — Avalanche/Arbitrum automated; Cronos manual instructions
- `scripts/deployment/check-balances-gas-and-deploy.sh` — Balance check includes Cronos
## Related Docs
- `docs/deployment/CRONOS_VERIFICATION_RUNBOOK.md` — Step-by-step manual verification with addresses and constructor args