diff --git a/src/pages/quickstart/verify-contracts.mdx b/src/pages/quickstart/verify-contracts.mdx new file mode 100644 index 00000000..053a53f1 --- /dev/null +++ b/src/pages/quickstart/verify-contracts.mdx @@ -0,0 +1,186 @@ +--- +title: Contract Verification +description: Verify your smart contracts on Tempo using contracts.tempo.xyz. Sourcify-compatible verification with Foundry integration. +--- + +# Contract Verification + +Verify your smart contracts on Tempo using [contracts.tempo.xyz](https://contracts.tempo.xyz), a Sourcify-compatible contract verification service. Verified contracts display source code and ABI in the [Tempo Explorer](https://explore.tempo.xyz), making it easier for users to interact with your contracts. + +## Verify with Foundry + +The easiest way to verify contracts is using Foundry's `forge verify-contract` command with the Sourcify verifier. + +```bash +forge verify-contract \ + --verifier sourcify \ + --verifier-url https://contracts.tempo.xyz \ + --chain-id 42431 \ + \ + src/MyContract.sol:MyContract +``` + +Replace `` with your deployed contract address and `src/MyContract.sol:MyContract` with the path and name of your contract. + +:::tip +Make sure you're using the same compiler settings (optimizer, EVM version) that you used when deploying the contract. +::: + +### Example + +After deploying a contract, verify it: + +```bash +# Deploy your contract +forge create src/Token.sol:Token --rpc-url https://rpc.moderato.tempo.xyz --private-key $PRIVATE_KEY + +# Verify the deployed contract +forge verify-contract \ + --verifier sourcify \ + --verifier-url https://contracts.tempo.xyz \ + --chain-id 42431 \ + 0x1234567890abcdef1234567890abcdef12345678 \ + src/Token.sol:Token +``` + +## Verify with the API + +You can also verify contracts directly using the REST API. Verification is asynchronous—you submit a request, then poll for the result. + +### Submit for Verification + +```bash +curl -X POST https://contracts.tempo.xyz/v2/verify/42431/ \ + -H 'Content-Type: application/json' \ + -d '{ + "stdJsonInput": { + "language": "Solidity", + "sources": { + "src/MyContract.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract MyContract { }" + } + }, + "settings": { + "optimizer": { "enabled": false, "runs": 200 }, + "evmVersion": "cancun" + } + }, + "compilerVersion": "0.8.20+commit.a1b79de6", + "contractIdentifier": "src/MyContract.sol:MyContract" + }' +``` + +The API returns `202 Accepted` with a verification ID: + +```json +{ + "verificationId": "550e8400-e29b-41d4-a716-446655440000" +} +``` + +:::tip +If verification has trouble determining the creation bytecode, include `creationTransactionHash` in the request body. +::: + +### Check Verification Status + +Poll the status endpoint until verification completes: + +```bash +curl https://contracts.tempo.xyz/v2/verify/ +``` + +The endpoint returns `200` for completed jobs, but you must check the response body to determine success or failure: + +```json +{ + "isJobCompleted": true, + "contract": { + "match": "exact_match", + "chainId": "42431", + "address": "0x1234567890abcdef1234567890abcdef12345678", + "name": "MyContract" + } +} +``` + +The `match` field can be `exact_match` (bytecode and metadata match), `match` (bytecode matches but metadata differs), or `null` (verification failed). + +### Retrieve Verified Contract + +Once verified, retrieve the contract details: + +```bash +curl https://contracts.tempo.xyz/v2/contract/42431/ +``` + +Add `?fields=all` to get full compilation artifacts including ABI, source files, and bytecode. + +## Vyper Support + +The verification service supports Vyper contracts. Use `"language": "Vyper"` in the `stdJsonInput`: + +```bash +curl -X POST https://contracts.tempo.xyz/v2/verify/42431/ \ + -H 'Content-Type: application/json' \ + -d '{ + "stdJsonInput": { + "language": "Vyper", + "sources": { + "contracts/Token.vy": { + "content": "# @version ^0.3.10\n..." + } + }, + "settings": {} + }, + "compilerVersion": "0.3.10+commit.91361694", + "contractIdentifier": "contracts/Token.vy:Token" + }' +``` + +## API Reference + +| Endpoint | Description | +|----------|-------------| +| `POST /v2/verify/{chainId}/{address}` | Submit contract for verification | +| `GET /v2/verify/{verificationId}` | Check verification status | +| `GET /v2/contract/{chainId}/{address}` | Get verified contract details | +| `GET /v2/contracts/{chainId}` | List all verified contracts | +| `GET /chains` | Get supported chains | + +View the full API documentation at [contracts.tempo.xyz/docs](https://contracts.tempo.xyz/docs). + +## Supported Chains + +| Network | Chain ID | +|---------|----------| +| Tempo Mainnet | `4217` | +| Tempo Testnet (Andantino) | `42429` | +| Tempo Testnet (Moderato) | `42431` | +| Tempo Devnet | `31318` | + +## Troubleshooting + +:::tip +If you encounter unexpected failures, you might be running an older version of Foundry/Forge, or you might not be running Tempo's Foundry fork. See the [Foundry setup guide](/quickstart/foundry) for installation instructions. +::: + +### Verification Failed + +If verification fails, check the following: + +- **Compiler version**: Use the full version string with commit hash (e.g., `0.8.20+commit.a1b79de6`) +- **Optimizer settings**: Optimizer enabled/disabled and runs must match deployment settings +- **EVM version**: Must match the EVM version used during deployment +- **Source files**: All imported files must be included in the `sources` object +- **Contract identifier**: Must match the format `path/to/Contract.sol:ContractName` + +### Common Errors + +| Error | Cause | +|-------|-------| +| `contract_not_found` | No bytecode exists at the address | +| `compilation_error` | Source code has syntax errors | +| `compilation_failed` | Compilation service returned an error | +| `contract_not_found_in_output` | Contract identifier not found in compiled output | +| `no_match` | Compiled bytecode doesn't match on-chain code | diff --git a/vocs.config.ts b/vocs.config.ts index 6ba20d90..7607e205 100644 --- a/vocs.config.ts +++ b/vocs.config.ts @@ -94,6 +94,10 @@ export default defineConfig({ text: 'Wallet Developers', link: '/quickstart/wallet-developers', }, + { + text: 'Contract Verification', + link: '/quickstart/verify-contracts', + }, { text: 'Building with AI', link: '/guide/building-with-ai',