### Start Sourcify UI Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/self-hosted-sourcify/setup.md Starts the Sourcify user interface. This command is used after building the UI components and is essential for interacting with the local Sourcify instance. ```sh npm run ui:start ``` -------------------------------- ### Run Otterscan Development Build Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/other.md This snippet details the process of setting up and running the Otterscan development build. It involves installing dependencies using npm ci and then starting the development server with npm start. This requires Node.js and npm to be installed. ```bash npm ci npm start ``` -------------------------------- ### Start Sourcify Server Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/self-hosted-sourcify/setup.md Starts the Sourcify server in development mode. The `NODE_ENV=development` environment variable is set to ensure the server runs with development configurations. ```sh NODE_ENV=development npm run server:start ``` -------------------------------- ### Launch Erigon Local Chain Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/self-hosted-sourcify/setup.md Starts a local Erigon Ethereum RPC node with specific API configurations for development. It requires the `--chain=dev` and `--mine` flags, and supports `ots` and `ots2` APIs. Note that the Erigon devnet is pre-Shanghai and requires `evmTarget` to be set to `london` for contract compatibility. ```sh ./erigon \ --chain=dev \ --datadir=dev \ --http.api eth,erigon,trace,ots,ots2 \ --http.corsdomain "*" \ --http.vhosts "*" \ --mine \ --fakepow ``` -------------------------------- ### Host Sourcify Repository with Caddy Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/lightweight-sourcify-server.md This command starts a Caddy file server to host the extracted Sourcify repository files on localhost:7877. ```sh caddy file-server --root ./repositoryV2/ --listen 127.0.0.1:7877 ``` -------------------------------- ### Start Development HTTP Server Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/assets-server.md This Python command starts a simple, single-threaded HTTP server in the current directory, which can be used in development environments to serve the assets. The server will be accessible at http://localhost:5175. ```python python3 -m http.server 5175 ``` -------------------------------- ### Start and Stop Otterscan Assets Server Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/other.md These commands are used to manage the Nginx Docker image that serves external data sources like icons and signatures for the Otterscan development build. It requires npm and Docker to be installed. ```bash npm run assets-start npm run assets-stop ``` -------------------------------- ### Example: Search Transactions After Genesis Block (Shell) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots-api.md An example using `curl` to call the `ots_searchTransactionsAfter` method, searching for the first 5 transactions associated with the Uniswap V1 router address starting from the genesis block. ```sh curl \ -X POST \ -H "Content-Type: application/json" \ --data \ '{ "jsonrpc":"2.0", "id": 1, "method":"ots_searchTransactionsAfter", "params": [ "0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95", 0, 5 ] }' \ http://127.0.0.1:8545 ``` -------------------------------- ### Configure Local Chain in Sourcify Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/self-hosted-sourcify/setup.md Creates a `sourcify-chains.json` file to add support for a local blockchain within the Sourcify server. This involves specifying the chain ID, a sourcify name, supported status, and the RPC endpoint. The example uses chain ID `1337` and RPC `http://localhost:8545`, common for Erigon devnet. ```json { "1337": { "sourcifyName": "Local chain", "supported": true, "rpc": [ "http://localhost:8545" ] } } ``` -------------------------------- ### Serve Otterscan Book Locally Source: https://github.com/otterscan/otterscan-book/blob/main/CLAUDE.md Starts a local HTTP server for live preview of the Otterscan documentation during editing. The server typically runs at http://localhost:3000/. ```shell mdbook serve ``` -------------------------------- ### Clone Sourcify Repository Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/self-hosted-sourcify/setup.md Clones the official Sourcify repository from GitHub to set up a local Sourcify instance. This is the first step in integrating Sourcify with Otterscan for local development. ```sh git clone https://github.com/ethereum/sourcify.git ``` -------------------------------- ### Build Sourcify Components Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/self-hosted-sourcify/setup.md Executes a script to build all necessary Sourcify components, including the server and UI. The `npm run build:clean` command ensures a clean build process for the Sourcify project. ```sh npm run build:clean ``` -------------------------------- ### Run Otterscan Development Image Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/dockerhub.md Executes a helper script to pull and run the latest development build of Otterscan. It requires the Erigon RPC URL and CL REST API URL as arguments. ```bash ./scripts/run-ots-develop.sh ``` -------------------------------- ### Example cURL Call Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots-api.md Demonstrates how to call Otterscan RPC methods using cURL, assuming the rpcdaemon is running locally on port 8545. ```bash curl --data '{"jsonrpc": "2.0", "method": "ots_getApiLevel", "params": [], "id": 1}' http://127.0.0.1:8545 ``` -------------------------------- ### Update Sourcify UI Repository URL Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/self-hosted-sourcify/setup.md Modifies the `.env.development` file in the Sourcify UI to set the `REACT_APP_REPOSITORY_SERVER_URL`. This configuration points the UI to the local Sourcify repository server, which is necessary for using the local instance. ```sh REACT_APP_REPOSITORY_SERVER_URL=http://localhost:5555/repository ``` -------------------------------- ### Get All Contracts List (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves a paginated list of all deployed contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getAllContractsList() ``` -------------------------------- ### Configure Otterscan for Local Sourcify Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/self-hosted-sourcify/setup.md Specifies the local Sourcify repository within the Otterscan configuration file. This JSON snippet configures Otterscan to use a local Sourcify instance by providing its URL and backend format. ```json { "sourcify": { "sources": { "Local Sourcify Repo": { "url": "http://localhost:5555/repository", "backendFormat": "RepositoryV2" }, "Sourcify Servers": { "url": "https://repo.sourcify.dev", "backendFormat": "RepositoryV1" } } } } ``` -------------------------------- ### Run Otterscan Docker with Erigon URL Override Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/dockerhub.md Runs the Otterscan Docker image, overriding the default Erigon RPC URL with a custom one using the ERIGON_URL environment variable. ```bash docker run --rm -p 5100:80 --name otterscan -d --env ERIGON_URL="" otterscan/otterscan: ``` -------------------------------- ### Run Otterscan Docker with Full Configuration Override Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/dockerhub.md Runs the Otterscan Docker image with a complete configuration specified via the OTTERSCAN_CONFIG environment variable in JSON format. This allows customization of Erigon URL, assets prefix, and branding. ```bash docker run \ --rm \ -p 5100:80 \ --name otterscan \ -d \ --env OTTERSCAN_CONFIG='{ "erigonURL": "http://127.0.0.1:8545", "assetsURLPrefix": "http://127.0.0.1:5175", "branding": { "siteName": "My Otterscan", "networkTitle": "Dev Network" }, }' \ otterscan/otterscan:latest ``` -------------------------------- ### Get ERC1167 List (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves a paginated list of ERC1167 minimal proxy contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC1167List() ``` -------------------------------- ### Enable OTS2 API and Experimental Mode in Erigon Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/ots2.md This snippet shows how to modify Erigon's command-line arguments to enable the 'ots2' API namespace and the experimental OTS2 feature. This is a prerequisite for using the experimental indexers. ```sh erigon \ --http.api "eth,erigon,trace,ots,ots2" \ --experimental.ots2 \ [] ``` -------------------------------- ### Get Contract Creator Information Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots-api.md Fetches the transaction hash and address responsible for creating a specific contract. This information is not available through standard Ethereum JSON-RPC methods. ```json { "jsonrpc": "2.0", "method": "ots_getContractCreator", "params": ["0x..."], "id": 1 } ``` -------------------------------- ### Anvil Otterscan API Implementation Source: https://github.com/otterscan/otterscan-book/blob/main/src/intro/networks.md Anvil, a local development network tool, implements the Otterscan API. This allows users to connect their Otterscan installation to an Anvil RPC endpoint to explore local devnets. ```Markdown Anvil [implements the Otterscan API](https://getfoundry.sh/anvil/reference/#otterscan-methods), so you can point your Otterscan installation to an Anvil RPC endpoint and have an explorer for your local devnet. ``` -------------------------------- ### Example: Search Transactions Response (JSON) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots-api.md A sample JSON response for the `ots_searchTransactionsAfter` call, showing transaction details like block hash, block number, sender, gas, hash, input data, and receiver. ```json { "jsonrpc": "2.0", "id": 1, "result": { "txs": [ { "blockHash": "0x06a77abe52c486f58696665eaebd707f17fbe97eb54480c6533db725769ce3b7", "blockNumber": "0x652284", "from": "0xd1c24f50d05946b3fabefbae3cd0a7e9938c63f2", "gas": "0xf4240", "gasPrice": "0x2cb417800", "hash": "0x14455f1af43a52112d4ccf6043cb081fea4ea3a07d90dd57f2a9e1278114be94", "input": "0x1648f38e000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498", "nonce": "0x6", "to": "0xc0a47dfe034b400b47bdad5fecda2621de6c4d95", "transactionIndex": "0x71", ... } } ``` -------------------------------- ### Otterscan Chain Configuration Example (JSON) Source: https://github.com/otterscan/otterscan-book/blob/main/src/config/options/chains.md This JSON snippet demonstrates the structure required to define a custom blockchain network for Otterscan. It includes the chain's name, a list of faucets, and details about its native currency, such as its name, symbol, and decimal places. ```json { "name": "Sepolia Testnet", "faucets": [], "nativeCurrency": { "name": "Sepolia Ether", "symbol": "sepETH", "decimals": 18 } } ``` -------------------------------- ### Run Otterscan Docker Image Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/dockerhub.md Downloads and runs the official Otterscan Docker image locally. It binds the container to port 5100 and names the container 'otterscan'. The image tag can be specified for different releases or the 'develop' tag for the latest development build. ```bash docker run --rm -p 5100:80 --name otterscan -d otterscan/otterscan: ``` -------------------------------- ### Enable OTS2 Mode in Otterscan Docker Container Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/ots2.md This snippet demonstrates how to enable the experimental OTS2 mode in Otterscan by setting the 'OTS2=true' environment variable when running the Docker container. This allows Otterscan to utilize the experimental indexers. ```sh docker run \ --rm \ --name otterscan \ -d \ -p 5100:80 \ --env ERIGON_URL="" \ --env OTS2=true \ otterscan/otterscan:v2.3.0 ``` -------------------------------- ### Get Block Details Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots-api.md An expanded version of `eth_getBlock*` tailored for Otterscan's block details page. It omits verbose fields like transaction lists and logs, and includes issuance and block fees information. ```json { "jsonrpc": "2.0", "method": "ots_getBlockDetails", "params": [1234567], "id": 1 } ``` -------------------------------- ### Caddyfile for Hosting Sourcify Repository Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/lightweight-sourcify-server.md This Caddyfile configuration sets up Caddy to serve the Sourcify RepositoryV2 from the './repositoryV2' directory on localhost:7877. ```caddyfile # Caddyfile for hosting Sourcify RepositoryV2 localhost:7877 { # Set the root directory to the extracted repository folder root * ./repositoryV2 # Serve files from the repository file_server } ``` -------------------------------- ### Stop Otterscan Docker Container Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/dockerhub.md Stops the running Otterscan Docker container named 'otterscan'. ```bash docker stop otterscan ``` -------------------------------- ### Download Sourcify Repository Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/lightweight-sourcify-server.md This snippet downloads the Sourcify repository manifest and all contract files using curl, then extracts the compressed archive. ```sh curl -L -O https://repo-backup.sourcify.dev/manifest.json jq -r '.files[].path' manifest.json | xargs -I {} curl -L -O https://repo-backup.sourcify.dev/{} cat sourcify-repository-*.part.gz.* | tar -xz ``` -------------------------------- ### Get ERC1155 Count (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves the total count of ERC1155 contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC1155Count() ``` -------------------------------- ### Build and Run Otterscan Docker Image Locally Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/other.md This snippet demonstrates how to clone the Otterscan repository, build a local Docker image using npm, and then start or stop the running container. It's an alternative to using pre-built Docker Hub images and requires Git and Docker. ```bash git clone https://github.com/otterscan/otterscan.git cd otterscan npm run docker-build npm run docker-start npm run docker-stop ``` -------------------------------- ### Get ERC1155 List (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves a paginated list of ERC1155 contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC1155List() ``` -------------------------------- ### Get All Contracts Count (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves the total count of all deployed contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getAllContractsCount() ``` -------------------------------- ### Set Up Symbolic Links for Assets Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/assets-server.md These bash commands create symbolic links to the external data repositories, organizing them into the required structure for the assets server. This includes linking chain data, signatures, topic0, and token logos. ```bash ln -s ../external-repos/chains/_data/chains chains ln -s ../external-repos/4bytes/signatures signatures ln -s ../external-repos/topic0/with_parameter_names topic0 mkdir assets ln -s ../external-repos/trustwallet-assets/blockchains/ethereum/assets ./assets/1 ``` -------------------------------- ### Get ERC20 List (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves a paginated list of ERC20 contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC20List() ``` -------------------------------- ### Get ERC721 List (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves a paginated list of ERC721 contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC721List() ``` -------------------------------- ### Build Otterscan Book Source: https://github.com/otterscan/otterscan-book/blob/main/CLAUDE.md Builds the Otterscan documentation book using mdbook. The compiled HTML output will be placed in the 'book' subdirectory. ```shell mdbook build ``` -------------------------------- ### Get ERC721 Count (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves the total count of ERC721 contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC721Count() ``` -------------------------------- ### Create Assets Server Directory Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/assets-server.md This bash command creates the main directory for the assets server contents. ```bash mkdir assets-contents cd assets-contents ``` -------------------------------- ### Get ERC20 Count (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves the total count of ERC20 contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC20Count() ``` -------------------------------- ### Deploy and Verify Contract with Forge Create Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/self-hosted-sourcify/verification.md This command shows how to deploy a smart contract using `forge create` and simultaneously verify it with Sourcify. It includes options for interactive deployment, optimization, RPC URL, and constructor arguments. ```sh ./forge create \ --verify \ --verifier sourcify \ --verifier-url http://localhost:5555/ \ --interactive \ --optimize \ --rpc-url http://localhost:8545/ MyContract \ --constructor-args 0x67b1d87101671b127f5f8714789C7192f7ad340e 123456 ``` -------------------------------- ### Get Block Details by Hash Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots-api.md Retrieves detailed block information using a block hash as input, similar to `ots_getBlockDetails` but with hash-based lookup. ```json { "jsonrpc": "2.0", "method": "ots_getBlockDetailsByHash", "params": ["0x..."], "id": 1 } ``` -------------------------------- ### Get ERC4626 List (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves a paginated list of ERC4626 vault contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC4626List() ``` -------------------------------- ### Configure Otterscan for Local Sourcify Repository Source: https://github.com/otterscan/otterscan-book/blob/main/src/contract-verification/lightweight-sourcify-server.md This JSON configuration snippet shows how to update Otterscan's settings to use a locally hosted Sourcify repository. ```json "sourcify": { "sources": { "Local Sourcify Repo": { "url": "http://localhost:7877", "backendFormat": "RepositoryV2" }, "Sourcify Servers": { "url": "https://repo.sourcify.dev", "backendFormat": "RepositoryV1" } } } ``` -------------------------------- ### Get ERC4626 Count (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves the total count of ERC4626 vault contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC4626Count() ``` -------------------------------- ### Configure Otterscan with VITE_CONFIG_JSON Source: https://github.com/otterscan/otterscan-book/blob/main/src/config/reading/devel.md This snippet demonstrates how to configure Otterscan for development by defining the `VITE_CONFIG_JSON` variable in a `.env.development.local` file. This JSON object specifies essential settings such as the Erigon URL, Beacon API endpoint, asset URL prefix, experimental chain ID, chain information (name, faucets, native currency), and Sourcify server configurations. ```env VITE_CONFIG_JSON=' { "erigonURL": "http://your-erigon-node-ip:8545", "beaconAPI": "http://your-beacon-node-ip:5052", "assetsURLPrefix": "http://localhost:5175", "experimentalFixedChainId": 11155111, "chainInfo": { "name": "Sepolia Testnet", "faucets": [], "nativeCurrency": { "name": "Sepolia Ether", "symbol": "SEPETH", "decimals": 18 } }, "sourcify": { "sources": { "Sourcify Servers": { "url": "https://repo.sourcify.dev", "backendFormat": "RepositoryV1" } } } } ' ``` -------------------------------- ### Get ERC1167 Count (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves the total count of ERC721 minimal proxy contracts. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC1167Count() ``` -------------------------------- ### Get ERC20 Holdings (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Given a specific address, returns all ERC20 tokens that have interacted with it. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC20Holdings() ``` -------------------------------- ### Get ERC1167 Implementation (ots2) Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots2-api.md Retrieves the logical contract associated with an ERC1167 minimal proxy. This method is part of the Otterscan v2 API. ```SQL SELECT ots2_getERC1167Impl() ``` -------------------------------- ### Lighthouse Beacon CLI Arguments for Otterscan Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/beacon-chain/lighthouse.md Configures the Lighthouse Beacon node to serve data to Otterscan. It specifies HTTP listening addresses, CORS origins, and essential backfilling parameters for complete historical data synchronization. ```sh lighthouse beacon \ --http \ --http-address "0.0.0.0" \ [--http-port ] \ --http-allow-origin '*' \ --genesis-backfill \ [--disable-backfill-rate-limiting ] \ [] ``` -------------------------------- ### Erigon Arguments for Caplin Source: https://github.com/otterscan/otterscan-book/blob/main/src/install/beacon-chain/caplin.md This snippet lists the essential Erigon command-line arguments required to activate and configure Caplin's features, including internal CL support, archive node capabilities, and historical data backfilling. It also specifies settings for the beacon chain REST API. ```bash --internalcl --caplin.archive --caplin.backfilling --caplin.backfilling.blob --caplin.backfilling.blob.no-pruning --beacon.api "beacon,builder,config,debug,events,node,validator,lighthouse" --beacon.api.addr "0.0.0.0" --beacon.api.port --beacon.api.cors.allow-methods "GET,OPTIONS" --beacon.api.cors.allow-origins '*' ``` -------------------------------- ### Get Transaction by Sender and Nonce Source: https://github.com/otterscan/otterscan-book/blob/main/src/api-docs/ots-api.md Retrieves the transaction hash for a given sender address and nonce. This is useful for navigating transactions from the same sender and is not supported by standard JSON-RPC APIs. ```json { "jsonrpc": "2.0", "method": "ots_getTransactionBySenderAndNonce", "params": ["0x...", 5], "id": 1 } ```