### Start Sourcify Server Source: https://docs.sourcify.dev/docs/running-server/index Starts the Sourcify server application. Ensure all previous setup steps, including dependency installation, database setup, and building, have been completed. ```bash npm start ``` -------------------------------- ### Install, Build, Test, and Run Sourcify 4byte Service (Node.js) Source: https://docs.sourcify.dev/docs/running-4byte Commands to install dependencies, build the service, run local tests, and start the development server for the Sourcify 4byte Service. Requires Node.js 22 and a PostgreSQL database. ```bash # Install dependencies npm install # Build the service npm run build # Run tests npm run test-local # Start development server npm run dev ``` -------------------------------- ### Clone Repository and Install Dependencies (npm/yarn) Source: https://docs.sourcify.dev/docs/repo.sourcify Instructions for cloning the project repository and installing its dependencies using either npm or yarn. This is a standard setup step for most Node.js projects. ```bash git clone https://github.com/sourcifyeth/repo.sourcify.dev.git cd repo.sourcify.dev npm install # or yarn install ``` -------------------------------- ### Project Setup and Local Testing Commands Source: https://docs.sourcify.dev/docs/chain-support These shell commands are used to set up the project, build it, and run local tests for newly added chains. This includes installing dependencies, building the project, and executing a local test suite that requires Docker Compose. ```bash npm install npx lerna run build export NEW_CHAIN_ID=1,11155111 && npm run test-local:chains ``` -------------------------------- ### Install Project Dependencies with npm or yarn Source: https://docs.sourcify.dev/docs/repo.sourcify.dev/index These commands install the necessary project dependencies using either npm or yarn. Ensure you have Node.js and a package manager installed. ```bash npm install ``` ```bash yarn install ``` -------------------------------- ### Build and Start Production Server (npm/yarn) Source: https://docs.sourcify.dev/docs/repo.sourcify Commands to build the Next.js application for production and start the production server using npm or yarn. This prepares the application for deployment. ```bash npm run build npm start # or yarn build yarn start ``` -------------------------------- ### Install @ethereum-sourcify/compilers using npm Source: https://docs.sourcify.dev/docs/compilers This command installs the @ethereum-sourcify/compilers package, which provides a wrapper around multiple compilers for downloading the right version and invoking the compilation with a common interface. ```bash npm i @ethereum-sourcify/compilers ``` -------------------------------- ### Start Sourcify UI Production Server Source: https://docs.sourcify.dev/docs/verify.sourcify Starts the production server for the Sourcify Verification UI after the application has been built. This command is used for deploying and running the application in a production environment. ```bash npm start ``` -------------------------------- ### Install Project Dependencies Source: https://docs.sourcify.dev/docs/verify.sourcify Installs the necessary Node.js dependencies for the Sourcify Verification UI project using npm. Ensure Node.js (version 20+) and npm are installed prior to running this command. ```bash npm install ``` -------------------------------- ### Install Node.js Dependencies Source: https://docs.sourcify.dev/docs/running-server/index Installs all necessary project dependencies using npm. This is a prerequisite for local development and building the Sourcify monorepo. ```bash npm install ``` -------------------------------- ### Install and Build Sourcify Monitor (Bash) Source: https://docs.sourcify.dev/docs/running-monitor/index These commands install project dependencies using npm and then build the sourcify-monitor package within the monorepo using Lerna. This prepares the service for execution. ```bash npm install npx lerna run build --scope sourcify-monitor ``` -------------------------------- ### Install Bytecode Utils Package Source: https://docs.sourcify.dev/docs/bytecode-utils Install the @ethereum-sourcify/bytecode-utils package using yarn. This is the primary dependency for using the decoding functionalities. ```bash yarn add @ethereum-sourcify/bytecode-utils ``` -------------------------------- ### Install lib-sourcify with npm Source: https://docs.sourcify.dev/docs/lib-sourcify This command installs the lib-sourcify package using npm. It is a prerequisite for using the library in your Node.js project. ```bash npm install @ethereum-sourcify/lib-sourcify ``` -------------------------------- ### Start Sourcify UI Development Server Source: https://docs.sourcify.dev/docs/verify.sourcify Starts the development server for the Sourcify Verification UI, enabling live reloading and development features. The application will typically be accessible at http://localhost:5173. ```bash npm run dev ``` -------------------------------- ### Database Setup and Migration (Bash) Source: https://docs.sourcify.dev/docs/running-server This snippet outlines the steps to set up the PostgreSQL database, including copying the environment template, setting database credentials, and running migrations to create the database schema. It assumes a Node.js environment with npm. ```bash cd ../database cp .env.template .env npm run migrate:up ``` -------------------------------- ### Run Development Server (npm/yarn) Source: https://docs.sourcify.dev/docs/repo.sourcify Commands to start the Next.js development server using npm or yarn. This allows for local development and testing of the application. ```bash npm run dev # or yarn dev ``` -------------------------------- ### Example Creation Values (JSON) Source: https://docs.sourcify.dev/docs/transformations Provides the associated values for creation transformations, detailing 'libraries', 'constructorArguments', and 'cborAuxdata' to be inserted or replaced. ```json { "libraries": { "sources/lib/MyLib.sol:MyLib": "0x40b70a4904fad0ff86f8c901b231eac759a0ebb0" }, "constructorArguments": "0x00000000000000000000000085fe79b998509b77bf10a8bd4001d58475d29386", "cborAuxdata": { "0": "0xa26469706673582212201c37bb166aa1bc4777a7471cda1bbba7ef75600cd859180fa30d503673b99f0264736f6c63430008190033" } } ``` -------------------------------- ### Set Supported Chains Configuration Source: https://docs.sourcify.dev/docs/running-server Copies the example chains configuration file to src/sourcify-chains.json. This file defines the smart contract chains that the Sourcify server will support. Modify this file to customize supported chains. ```bash cp src/sourcify-chains-example.json src/sourcify-chains.json ``` -------------------------------- ### Runtime Transformations Example 1 (JSON) Source: https://docs.sourcify.dev/docs/transformations/index Illustrates runtime transformations for libraries, immutable variables, and CBOR auxdata, showing their respective types, offsets, and reasons for modification. ```json [ { "id": "contracts/order/OrderUtils.sol:OrderUtilsLib", "type": "replace", "offset": 449, "reason": "library" }, { "id": "2473", "type": "replace", "offset": 4339, "reason": "immutable" }, { "id": "1", "type": "replace", "offset": 4682, "reason": "cborAuxdata" } ] ``` -------------------------------- ### Example Runtime Transformations - Libraries and Immutables (JSON) Source: https://docs.sourcify.dev/docs/transformations Demonstrates runtime transformations for libraries and immutable variables, including their types, offsets, and specific IDs for referencing. ```json [ { "id": "contracts/order/OrderUtils.sol:OrderUtilsLib", "type": "replace", "offset": 449, "reason": "library" }, { "id": "2473", "type": "replace", "offset": 4339, "reason": "immutable" } { "id": "1", "type": "replace", "offset": 4682, "reason": "cborAuxdata" } ] ``` -------------------------------- ### Example Runtime Transformations (JSON) Source: https://docs.sourcify.dev/docs/transformations Illustrates the structure of runtime transformations, specifying changes like 'replace' or 'insert' operations at specific byte offsets with reasons such as 'immutable' or 'auxdata'. ```json [ { "id": "20", "type": "replace", "offset": 137, // in bytes "reason": "immutable" }, { "id": "0", "type": "replace", "offset": 1002, "reason": "auxdata" } ] ``` -------------------------------- ### Navigate to Database Directory and Run Sync Script Source: https://docs.sourcify.dev/docs/database-migration/index This sequence of commands navigates to the 'services/database' directory and then executes the 'sourcify:database sync' npm script. The script requires the URL of the Sourcify migration instance, the path to the repository contracts, a list of unsupported chains, and an optional limit for concurrent verifications. ```bash cd services/database npm run sourcify:database sync URL_TO_SOURCIFY_MIGRATION_INSTANCE /data/repository/contracts/ -- -c LIST_OF_UNSUPPORTED_CHAINS --limit 5 ``` -------------------------------- ### Migrate Solidity Contract Verification from v1 to v2 (JavaScript) Source: https://docs.sourcify.dev/docs/lib-sourcify This example shows the migration process for verifying Solidity contracts from lib-sourcify v1 to v2. It contrasts the older approach using SolidityCheckedContract with the new v2 workflow involving createMetadataContractsFromFiles, fetchMissing, createCompilation, and the Verification class. The v2 approach offers more explicit control over validation, compilation, and verification steps. ```javascript // V1 code const checkedContracts = await checkFilesWithMetadata(solc, pathBuffers); const solidityCheckedContract = checkedContracts[0]; await solidityCheckedContract.fetchMissing(); const match = await verifyDeployed( solidityCheckedContract, sourcifyChain, contractAddress, ); ``` ```javascript // V2 code import { createMetadataContractsFromFiles, Verification, } from '@ethereum-sourcify/lib-sourcify'; // Create metadata contracts from files const metadataContracts = await createMetadataContractsFromFiles(pathBuffers); const metadataContract = metadataContracts[0]; // Fetch missing sources await metadataContract.fetchMissing(); // Create compilation const compilation = await metadataContract.createCompilation(solc); // Create verification instance const verification = new Verification( compilation, sourcifyChain, contractAddress, ); // Perform verification await verification.verify(); // Check verification status const status = verification.status; ``` -------------------------------- ### Run Sourcify Server with Docker Compose Source: https://docs.sourcify.dev/docs/running-server This command starts the Sourcify server using Docker Compose. It sets up a PostgreSQL database, runs necessary migrations, and launches the server, exposing port 5555. This is suitable for quick testing but not recommended for production. ```bash cd ../.. docker compose -f ./services/server/docker-compose.yml up ``` -------------------------------- ### Run Database Migrations Source: https://docs.sourcify.dev/docs/running-server Applies database migrations to set up the schema. Ensure the DATABASE_URL in the .env file is correctly configured for your PostgreSQL instance before running this command. ```bash cd services/database npm run migrate:up ``` -------------------------------- ### Start PostgreSQL Container with Docker Compose Source: https://docs.sourcify.dev/docs/running-server Starts a PostgreSQL database instance in detached mode using Docker Compose within the services/database directory. This option is for running a local Postgres container. ```bash cd services/database docker compose up -d ``` -------------------------------- ### Vyper CBOR Auxdata Example Source: https://docs.sourcify.dev/docs/immutables Provides an example of the CBOR auxdata array format used by Vyper. This illustrates the typical values and structure found at the end of a Vyper contract's creation bytecode. ```json [167, [10], 96, {"vyper": [0, 4, 0]}] ``` -------------------------------- ### Smart Contract Bytecode Example Source: https://docs.sourcify.dev/docs/what-is-source-code-verification This snippet displays an example of smart contract bytecode, which is the machine-readable '1s and 0s' representation of a smart contract deployed on a blockchain. This bytecode is what is stored on-chain and is compared against compiled source code during verification. ```bytecode 0x608060405234801561001057600080fd5b50600436106100365760003560e01c80632e64cec11461003b5780636057361d14610059575b600080fd5b610043610075565b60405161005091906100d9565b60405180910390f35b610073600480360381019061006e919061009d565b61007e565b005b60008054905090565b8060008190555050565b60008135905061009781610103565b92915050565b6000602082840312156100b3576100b26100fe565b5b60006100c184828501610088565b91505092915050565b6100d3816100f4565b82525050565b60006020820190506100ee60008301846100ca565b92915050565b6000819050919050565b600080fd5b61010c816100f4565b811461011757600080fd5b5056fea2646970667358221220404e37f487a89a932dca5e77faaf6ca2de3b991f93d230604b1b8daaef64766264736f6c63430008070033 ``` -------------------------------- ### Example API Request with Pagination Source: https://docs.sourcify.dev/docs/repository/download-dataset/index This example demonstrates how to construct a URL to list objects from the Sourcify export API with specific filtering and pagination parameters. It utilizes prefix, max-keys, and marker to retrieve a subset of data and enable further pagination. ```URL https://export.sourcify.dev/?prefix=v2/verified_contracts/&max-keys=2&marker=v2/verified_contracts/verified_contracts_1000000_2000000.parquet ``` -------------------------------- ### GET /v2/verify/{verificationId} Source: https://docs.sourcify.dev/docs/api Retrieves the status and results of a previously initiated contract verification process using its verification ID. ```APIDOC ## GET /v2/verify/{verificationId} ### Description Retrieves the status and results of a previously initiated contract verification process using its verification ID. ### Method GET ### Endpoint `/v2/verify/{verificationId}` ### Parameters #### Path Parameters - **verificationId** (string) - Required - The ID obtained from the verification initiation request. #### Query Parameters None #### Request Body None ### Request Example (No request body needed for this GET request) ### Response #### Success Response (200) - **status** (string) - The current status of the verification (e.g., "success", "failed", "pending"). - **result** (object) - The verification results if successful. #### Response Example ```json { "status": "success", "result": { "// SPDX-License-Identifier: MIT": "", "pragma solidity ^0.8.0;": "", "contract Storage {": "", " uint256 number;": "", " function setNumber(uint256 newNumber) public {": "", " number = newNumber;": "", " }": "", " function getNumber() public view returns (uint256) {": "", " return number;": "", " }": "" "}": "" } } ``` ``` -------------------------------- ### Migrate Database Schema using npm Source: https://docs.sourcify.dev/docs/database-migration/index This command initiates the database schema migration process for Sourcify. It requires navigating to the `services/database` directory, configuring `database.json`, and then running the migration script with the appropriate environment configuration. ```bash cd services/database npm run migrate:up -- --env=YOUR_ENV ``` -------------------------------- ### Clone Sourcify Monorepo (Bash) Source: https://docs.sourcify.dev/docs/running-monitor/index This command clones the Sourcify monorepo from GitHub. After cloning, navigate into the project directory to proceed with installation and building. ```bash git clone git@github.com:argotorg/sourcify.git cd sourcify ``` -------------------------------- ### Example Runtime Values (JSON) Source: https://docs.sourcify.dev/docs/transformations Shows the associated values for runtime transformations, including mappings for 'immutables' and 'cborAuxdata', keyed by transformation IDs. ```json { "immutables": { "20": "0x000000000000000000000000b5d83c2436ad54046d57cd48c00d619d702f3814" }, "cborAuxdata": { "0": "0xa26469706673582212205817b060c918294cc8107069c4fd0a74dbfc35b0617214043887fe9d4e17a4a864736f6c634300081a0033" } } ``` -------------------------------- ### Checkout Git Tag for Sourcify Migration Source: https://docs.sourcify.dev/docs/database-migration/index This command checks out a specific Git tag, 'sourcify-server@1.6.0', or a commit hash '6cdcdce8f186cdf3c90438393fee1efcbe272622'. This is a prerequisite for starting the dedicated sourcify-server-migration instance. ```bash git checkout tags/sourcify-server@1.6.0 # or git checkout 6cdcdce8f186cdf3c90438393fee1efcbe272622 ``` -------------------------------- ### Deploy and Verify Contract with Foundry and Sourcify Source: https://docs.sourcify.dev/docs/verify-via-foundry/index This command deploys a new smart contract and simultaneously verifies it using the Sourcify verification provider. It requires the RPC URL, constructor arguments, private key, contract source path, and optionally a verifier URL. ```bash forge create --rpc-url \ --constructor-args "ForgeUSD" "FUSD" 18 1000000000000000000000 \ --private-key \ src/MyToken.sol:MyToken \ --verify \ --verification-provider sourcify --verifier-url https://localhost:5555 # optional, defaults to https://sourcify.dev/server/ ``` -------------------------------- ### GET /v2/contract/{chainId}/{address} Source: https://docs.sourcify.dev/docs/api Fetches detailed information about a verified smart contract. You can specify which fields to retrieve using the `fields` query parameter. ```APIDOC ## GET /v2/contract/{chainId}/{address} ### Description Fetches detailed information about a verified smart contract. You can specify which fields to retrieve using the `fields` query parameter. ### Method GET ### Endpoint `/v2/contract/{chainId}/{address}` ### Parameters #### Path Parameters - **chainId** (string) - Required - The chain ID of the network where the contract is deployed. - **address** (string) - Required - The address of the contract. #### Query Parameters - **fields** (string) - Optional - A comma-separated list of fields to retrieve (e.g., "all", "metadata", "source-code"). Defaults to "all" if not specified. #### Request Body None ### Request Example ```bash curl -sS \ 'https://sourcify.dev/server/v2/contract/11155111/0x2738d13E81e30bC615766A0410e7cF199FD59A83?fields=all' ``` ### Response #### Success Response (200) - **[field_name]** (any) - The requested details of the verified contract. #### Response Example ```json { "// SPDX-License-Identifier: MIT": "", "pragma solidity ^0.8.0;": "", "contract Storage {": "", " uint256 number;": "", " function setNumber(uint256 newNumber) public {": "", " number = newNumber;": "", " }": "", " function getNumber() public view returns (uint256) {": "", " return number;": "", " }": "" "}": "" } ``` ``` -------------------------------- ### Build Sourcify Server Source: https://docs.sourcify.dev/docs/running-server/index Builds the Sourcify server, which includes generating the final `dist/sourcify-chains.json` file based on the configured chains. This step is necessary before starting the server. ```bash npm run build ``` -------------------------------- ### Run Sourcify Server Docker Image (Bash) Source: https://docs.sourcify.dev/docs/running-server This command shows how to pull the latest Sourcify server image from the Github Container Registry and run it as a Docker container. It includes port mapping, volume mounts for custom configuration files, and environment file loading. ```bash $ docker pull ghcr.io/argotorg/sourcify/server:latest $ docker run \ -p 5555:5555 \ -v path/to/custom/sourcify-chains.json:/home/app/services/server/dist/sourcify-chains.json \ -v path/to/custom/config.js:/home/app/services/server/dist/config/local.js \ --env-file path/to/your-server/.env \ ghcr.io/argotorg/sourcify/server:latest ``` -------------------------------- ### Deploying Test Contracts with ts-node Source: https://docs.sourcify.dev/docs/chain-support This command demonstrates how to use `ts-node` to execute a script for deploying test contracts on a new chain. The `--help` flag provides information on how to use the script, including passing a private key for deployment. ```bash npx ts-node test/chains/deployContracts.ts --help ```