### Install and Start GraphQL Server Source: https://github.com/joshstevens19/rindexer/blob/master/graphql/README.md Run these commands to install dependencies and start the GraphQL server locally for development. Ensure Node.js and npm are installed. ```bash npm install npm start ``` -------------------------------- ### Install and Start GraphQL Server Source: https://github.com/joshstevens19/rindexer/blob/master/README.md Instructions for setting up and running the GraphQL server within the 'graphql' directory. Requires Node.js and npm. ```bash cd graphql npm install npm start ``` -------------------------------- ### New Project Initialization Example Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/create-new-project/standard.mdx This output shows an example of the interactive prompts and successful completion message when creating a new rindexer project. It guides through naming, description, repository, storage selection, and Docker support for PostgreSQL. ```bash Initializing new rindexer project... Project Name: RocketPoolETHIndexer Project Description (skip by pressing Enter): My first rindexer project Repository (skip by pressing Enter): https://github.com/joshstevens19/rindexer What Storages To Enable? (graphql can only be supported if postgres is enabled) [postgres, csv, both, none]: postgres Postgres Docker Support Out The Box? [yes, no]: yes rindexer no-code project created with a rETH transfer events YAML template. ``` -------------------------------- ### Install Dependencies Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/README.md Run this command to install project dependencies. ```bash npm i ``` -------------------------------- ### Start Rindexer Services (CLI) Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/running.mdx Use these commands to start the Rindexer indexer, GraphQL API, or both. The database will start automatically if not connected and docker-compose.yml is present. ```bash rindexer start all ``` ```bash rindexer start indexer ``` ```bash rindexer start graphql ``` -------------------------------- ### Example Network Configuration Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/add.mdx This is an example of how a network should be configured in your YAML file for the 'add contract' command to reference. ```yaml networks: - name: ethereum // [!code focus] chain_id: 1 rpc: https://mainnet.gateway.tenderly.co ``` -------------------------------- ### Setup Rindexer E2E Tests Source: https://github.com/joshstevens19/rindexer/blob/master/e2e-tests/README.md Commands to set up the development environment for Rindexer E2E tests, including dependency installation and binary builds. ```bash # Complete development setup make dev-setup ``` ```bash # Or step by step: make install-deps # Install Foundry and Anvil make build-rindexer # Build Rindexer binary make build # Build E2E test binary ``` -------------------------------- ### Example New Project Initialization with Reth Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/create-new-project/reth-mode.mdx This is an example of the interactive prompts and output when initializing a new rindexer project with Reth mode enabled. ```bash rindexer new no-code --reth Initializing new rindexer project with Reth support... Project Name: RocketPoolETHIndexer Project Description (skip by pressing Enter): High-performance rETH indexer using Reth Repository (skip by pressing Enter): https://github.com/joshstevens19/rindexer What Storages To Enable? (graphql can only be supported if postgres is enabled) [postgres, csv, both, none]: postgres Postgres Docker Support Out The Box? [yes, no]: yes Reth Configuration: Data Directory (default: ~/.reth): /data/reth Chain (default: mainnet) [mainnet, sepolia, holesky]: mainnet Enable HTTP RPC? [yes, no]: yes Auth RPC Port (default: 8551): 8551 rindexer no-code project created with Reth support with a rETH transfer events YAML template. ``` -------------------------------- ### Start All Services Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/create-new-project/reth-mode.mdx Use this command to start all services, including the Reth node and the indexer. ```bash rindexer start all ``` -------------------------------- ### Install Foundry Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/phantom.mdx Install Foundry, a required tool for compiling smart contracts. This command downloads and installs the latest version. ```bash curl -L https://foundry.paradigm.xyz | bash ``` -------------------------------- ### Start GraphQL Only Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/create-new-project/reth-mode.mdx Use this command to start only the GraphQL service. ```bash rindexer start graphql ``` -------------------------------- ### rindexer start Command Usage Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/references/cli.mdx Usage for the `start` command to run indexers, GraphQL APIs, or both. ```bash `rindexer start indexer` or `rindexer start graphql` or `rindexer start all` Usage: rindexer start [OPTIONS] Commands: indexer Starts the indexing service based on the rindexer.yaml file graphql Starts the GraphQL server based on the rindexer.yaml file all Starts the indexers and the GraphQL together based on the rindexer.yaml file help Print this message or the help of the given subcommand(s) Options: -p, --path optional - The path to run the command in, default will be where the command is run -y, --yes Auto-confirm all schema migration prompts. Useful for CI/CD pipelines. -w, --watch Watch rindexer.yaml for changes and hot-reload (no-code projects only). -h, --help Print help (see a summary with '-h') ``` -------------------------------- ### Example Phantom Contract Deployment Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/phantom.mdx An example of deploying the `RocketPoolETH` contract to the `ethereum` network. ```bash rindexer phantom deploy --contract-name RocketPoolETH --network ethereum ``` -------------------------------- ### Example Table Definitions Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/tables/index.mdx This example shows how to define two custom tables, 'balances' and 'metrics', for tracking token transfers and supply. ```APIDOC ## Putting It All Together A complete indexer with multiple tables: ```yaml name: DeFiDashboard project_type: no-code networks: - name: ethereum chain_id: 1 rpc: https://mainnet.gateway.tenderly.co storage: postgres: enabled: true contracts: - name: Token details: - network: ethereum address: "0x..." start_block: 18600000 abi: ./abis/ERC20.json tables: # Table 1: Individual balances - name: balances columns: - name: holder - name: balance default: "0" events: - event: Transfer operations: - type: upsert where: holder: $to if: "$to != 0x0000000000000000000000000000000000000000" set: - column: balance action: add value: $value - type: upsert where: holder: $from if: "$from != 0x0000000000000000000000000000000000000000" set: - column: balance action: subtract value: $value # Table 2: Global metrics - name: metrics global: true columns: - name: total_supply type: uint256 default: "0" - name: transfer_count type: uint256 default: "0" events: - event: Transfer operations: # Track mints - type: upsert if: "$from == 0x0000000000000000000000000000000000000000" set: - column: total_supply action: add value: $value # Track burns - type: upsert if: "$to == 0x0000000000000000000000000000000000000000" set: - column: total_supply action: subtract value: $value # Count all transfers - type: upsert set: - column: transfer_count action: increment ``` ``` -------------------------------- ### Example: Backfill Oracle Prices Every 100 Blocks Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/tables/index.mdx This example demonstrates backfilling oracle prices by setting an `interval` for live mode, `start_block` for historical sync, and `block_interval` to snapshot every 100 blocks. After historical sync, it switches to live mode. ```yaml cron: - interval: 15s # Live: poll every 15 seconds start_block: 24184625 # Historical: start from this block block_interval: 100 # Historical: snapshot every 100 blocks network: ethereum operations: - type: insert set: - column: price action: set value: $call($contract, "latestAnswer()") ``` -------------------------------- ### Run Development Server Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/README.md Execute this command to start the development server. ```bash npm run dev ``` -------------------------------- ### Start rindexer and GraphQL Server Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/tables/index.mdx Execute this command in your terminal to start both the rindexer data indexing process and the GraphQL server. The GraphQL server will be accessible at `http://localhost:3001/graphql`. ```bash rindexer start all ``` -------------------------------- ### Install Rindexer Helm Chart Source: https://github.com/joshstevens19/rindexer/blob/master/helm/rindexer/README.md Installs the Rindexer Helm chart with a specified release name using the default configuration. ```bash helm install my-release ./rindexer ``` -------------------------------- ### Real-World Example: Liquidation USD Value Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/tables/index.mdx This example demonstrates computing the USD value of liquidated collateral by combining raw amounts, oracle prices, and token decimals using arithmetic and view calls. ```yaml constants: oracle: ethereum: "0x54586bE62E3c3580375aE3723C145253060Ca0C2" arbitrum: "0xb56c2F0B653B2e0b10C9b928C8580Ac5Df02C7C7" contracts: - name: Pool abi: ./abis/AaveV3Pool.json details: - network: ethereum address: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2" start_block: 24263944 tables: - name: liquidations columns: - name: borrower - name: collateral_asset - name: collateral_amount_raw - name: total_usd_value type: uint256 # Result has 8 decimal precision from oracle events: - event: LiquidationCall operations: - type: insert set: - column: borrower action: set value: $user - column: collateral_asset action: set value: $collateralAsset - column: collateral_amount_raw action: set value: $liquidatedCollateralAmount - column: total_usd_value action: set # Formula: (amount * price) / 10^decimals # - $liquidatedCollateralAmount: raw amount from event # - getAssetPrice(): returns price with 8 decimals # - decimals(): returns token decimals (e.g., 18 for WETH) # Result: USD value with 8 decimal precision value: ($liquidatedCollateralAmount * $call($constant(oracle), "getAssetPrice(address)", $collateralAsset)) / (10 ^ $call($collateralAsset, "decimals()")) ``` -------------------------------- ### Start Indexer Only Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/create-new-project/reth-mode.mdx Use this command to start only the indexer service. ```bash rindexer start indexer ``` -------------------------------- ### Check rindexer Installation Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/introduction/installation.mdx Verifies that the rindexer CLI has been installed successfully by displaying the help information. ```bash rindexer --help ``` -------------------------------- ### Full Example: Chainlink Historical Cron Sync Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/tables/index.mdx A comprehensive configuration for Chainlink's historical cron sync, including network, storage, contract ABIs, and table definitions. It specifies live polling, historical start block, and block interval for snapshots. ```yaml name: Chainlink description: Demonstrates cron historical sync - replaying cron operations at past blocks repository: https://github.com/joshstevens19/rindexer project_type: no-code networks: - name: ethereum chain_id: 1 rpc: 'RPC' storage: postgres: enabled: true drop_each_run: true contracts: - name: ETHUSDFeed details: - network: ethereum address: "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" abi: ./abis/ChainlinkAggregator.json tables: - name: eth_price_historical_only columns: - name: price type: int256 cron: - interval: 15s # Live mode: poll every 15 seconds start_block: 24184625 block_interval: 100 # Execute every 100 blocks network: ethereum operations: - type: insert set: - column: price action: set value: $call($contract, "latestAnswer()") ``` -------------------------------- ### Example GraphQL Queries Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/tables/index.mdx Demonstrates how to query the automatically generated GraphQL API for custom tables like 'balances'. ```APIDOC ### Example Queries For a `balances` table, rindexer automatically generates queries like: ```graphql # Get all balances query { allBalances(first: 100, orderBy: BALANCE_DESC) { nodes { holder balance network lastUpdatedBlock lastUpdatedAt } pageInfo { hasNextPage endCursor } } } # Get a specific holder's balance query { allBalances(condition: { holder: "0x..." }) { nodes { holder balance network } } } # Filter by network query { allBalances(condition: { network: "ethereum" }, first: 50) { nodes { holder balance } } } ``` ``` -------------------------------- ### Example Contract Cloning Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/phantom.mdx Example of cloning a specific contract ('RocketPoolETH') on the 'ethereum' network using the rindexer CLI. This creates a 'phantom/ethereum/RocketPoolETH/' directory with project files. ```bash rindexer phantom clone --contract-name RocketPoolETH --network ethereum ``` -------------------------------- ### Install rindexer Helm Chart Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/deploying/gcp.mdx Installs the rindexer Helm chart using the specified `values.yaml` file. This command deploys the application to your Kubernetes cluster. ```bash helm install rindexer ./helm/rindexer -f helm/rindexer/values.yaml ``` -------------------------------- ### Start Rindexer with Indexing Enabled Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/health-monitoring.mdx The health server starts automatically when you run rindexer with indexing enabled. No additional configuration is required. ```bash rindexer start indexer rindexer start all ``` -------------------------------- ### Configure NGINX Ingress Controller Source: https://github.com/joshstevens19/rindexer/blob/master/helm/rindexer/README.md Example Helm values for configuring the NGINX Ingress Controller. ```yaml ingress: enabled: true annotations: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/rewrite-target: "/" hosts: - host: rindexer.local paths: - path: "/" pathType: Prefix ``` -------------------------------- ### Configure Advanced Settings Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/yaml-config/top-level-fields.mdx The `config` field allows for more advanced, opt-in configuration parameters. This example shows settings for `buffer` and `callback_concurrency`. ```yaml name: rETHIndexer description: My first rindexer project repository: https://github.com/joshstevens19/rindexer config: buffer: 2 callback_concurrency: 4 ``` -------------------------------- ### Install rindexer CLI (Latest) Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/introduction/installation.mdx Installs the latest version of the rindexer CLI using a curl script. Ensure you are using Git BASH or WSL on Windows. ```bash curl -L https://rindexer.xyz/install.sh | bash ``` -------------------------------- ### Native Transfers with Start Block Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/yaml-config/native-transfers.mdx Configure historical native transfer indexing by specifying a `start_block` within the `native_transfers.networks` configuration. If omitted, indexing starts from the latest block and continues live. ```yaml name: rIndexer description: My native transfers rindexer project repository: https://github.com/joshstevens19/rindexer project_type: no-code networks: - name: ethereum chain_id: 1 rpc: https://mainnet.gateway.tenderly.co native_transfers: networks: // [!code focus] - network: ethereum start_block: 0 // [!code focus] contracts: [] ``` -------------------------------- ### Rust Event Handler Example Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/tables/index.mdx Illustrates a traditional Rust approach to handling events and updating database balances, requiring manual code for each operation. ```rust async fn handle_transfer(event: Transfer, db: &Database) { // Fetch existing balance let balance = db.get_balance(&event.to).await?; // Calculate new balance let new_balance = balance + event.value; // Update database db.upsert_balance(&event.to, new_balance).await?; // Don't forget the sender... } ``` -------------------------------- ### Example RPC Metrics Output Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/metrics.mdx Sample output for RPC metrics, including total requests by status and aggregated request durations. ```text rindexer_rpc_requests_total{method="eth_getLogs",network="mainnet",status="success"} 156 rindexer_rpc_requests_total{method="eth_getLogs",network="mainnet",status="error"} 2 rindexer_rpc_request_duration_seconds_sum{method="eth_getLogs",network="mainnet"} 45.23 rindexer_rpc_request_duration_seconds_count{method="eth_getLogs",network="mainnet"} 156 ``` -------------------------------- ### Marking Live Indexing Tests in Rust Source: https://github.com/joshstevens19/rindexer/blob/master/e2e-tests/README.md Example of how to mark a test as a live indexing test using the `.as_live_test()` method in Rust. ```rust TestDefinition::new( "test_live_my_feature", "Test my live feature", my_live_test_function, ).with_timeout(120).as_live_test() ``` -------------------------------- ### Example Indexing Metrics Output Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/metrics.mdx Sample output for indexing-related Prometheus metrics, showing processed events, last synced block, and blocks behind. ```text rindexer_events_processed_total{contract="USDC",event="Transfer",network="ethereum"} 19971 rindexer_last_synced_block{contract="USDC",event="Transfer",network="ethereum"} 21901064 rindexer_blocks_behind{contract="USDC",event="Transfer",network="ethereum"} 2425731 ``` -------------------------------- ### Configure SNS for Native Transfers Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/streams/sns.mdx Example of configuring SNS streams for native transfers in rindexer. This setup is for streaming Ethereum native transfers. ```yaml name: ETHIndexer description: My first rindexer project repository: https://github.com/joshstevens19/rindexer project_type: no-code networks: - name: ethereum chain_id: 1 rpc: https://mainnet.gateway.tenderly.co native_transfers: networks: - network: ethereum streams: // [!code focus] sns: // [!code focus] aws_config: // [!code focus] region: us-east-1 // [!code focus] access_key: ${AWS_ACCESS_KEY_ID} // [!code focus] secret_key: ${AWS_SECRET_ACCESS_KEY} // [!code focus] # session_token is optional // [!code focus] session_token: ${AWS_SESSION_TOKEN} // [!code focus] # endpoint_url is optional // [!code focus] endpoint_url: ${ENDPOINT_URL} // ![code focus] topics: // [!code focus] - topic_arn: "arn:aws:sns:us-east-1:664643779377:ethereum-transfers" // [!code focus] networks: // [!code focus] - ethereum // [!code focus] ``` -------------------------------- ### Advanced Filtering with Greater Than Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/accessing-data/graphql.mdx This example shows how to use advanced filtering to get transfers with a value greater than a specified amount and after a certain block number. ```APIDOC ## Advanced Filtering with Greater Than ### Description This query retrieves the first 20 transfers that have a value greater than 1 rEth (represented as 1000000000000000000 wei) and occurred after block number 18600181. This utilizes the `filter` input for more complex conditions. ### Query ```graphql query AllTransfers { allTransfers(first: 20, condition: { value: "1000000000000000000", }, filter: { blockNumber: { greaterThan: "18600181" } }) { nodes { blockHash blockNumber contractAddress from network nodeId to txHash value } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } } } ``` ``` -------------------------------- ### Basic YAML Configuration with Environment Variable Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/yaml-config/index.mdx This example shows a basic rindexer project configuration using YAML. It includes project details, network settings with an RPC URL defined by an environment variable, storage configuration, and contract details with specific events to include. ```yaml name: rETHIndexer description: My first rindexer project repository: https://github.com/joshstevens19/rindexer project_type: no-code networks: - name: ethereum chain_id: 1 rpc: ${RPC_URL} // [!code focus] storage: postgres: enabled: true contracts: - name: RocketPoolETH details: - network: ethereum address: "0xae78736cd615f374d3085123a210448e74fc6393" start_block: 18600000 end_block: 18718056 abi: ./abis/RocketTokenRETH.abi.json include_events: - Transfer - Approval ``` -------------------------------- ### eRPC Configuration Example Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/references/rpc-node-providers.mdx Configure eRPC by defining log level and upstream endpoints for your projects. Ensure to replace placeholder API keys and endpoints with your actual details. ```yaml logLevel: debug projects: - id: main upstreams: # You don't need to define architecture (e.g. evm) or chain id (e.g. 137) # as they will be detected automatically by eRPC. - endpoint: https://eth-mainnet.blastapi.io/xxxx - endpoint: https://polygon-mainnet.blastapi.io/xxxx - endpoint: evm+alchemy://xxxx-my-alchemy-api-key-xxxx ``` -------------------------------- ### Initialize Railway Project Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/deploying/railway.mdx Initialize a new Railway project with a specified name. This command prepares your project for deployment on Railway. ```bash railway init --name rindexer-example ``` -------------------------------- ### Example Health Response Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/deploying/railway.mdx An example JSON response from the Rindexer health monitoring endpoint. This shows the structure and typical values for service status. ```json { "status": "healthy", "timestamp": "2024-01-15T10:30:00Z", "services": { "database": "healthy", "indexing": "healthy", "sync": "healthy" }, "indexing": { "active_tasks": 2, "is_running": true } } ``` -------------------------------- ### Create New Project (No-Code) Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/create-new-project/standard.mdx Use this command to start a new rindexer project without generating any specific code templates. This is useful for projects where you plan to write all logic from scratch. ```bash rindexer new no-code ``` -------------------------------- ### Use rindexer Docker Image with Existing Project Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/introduction/installation.mdx Sets environment variables for project path and database URL, then starts rindexer services using docker-compose. Assumes a running postgres instance. ```bash export PROJECT_PATH=/path/to/your/project export DATABASE_URL="postgresql://user:pass@postgres/db" docker-compose up -d ``` -------------------------------- ### Get Help for rindexer new command Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/introduction/installation.mdx Displays detailed help information for the 'rindexer new' command, useful for understanding project creation options. ```bash rindexer new --help ``` -------------------------------- ### GraphQL API Response Example Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/create-new-project/standard.mdx This is an example of a successful response from the GraphQL API when querying for all transfers. It includes the requested data in the 'nodes' field and pagination details in 'pageInfo'. ```json { "data": { "allTransfers": { "nodes": [ { "blockHash": "0x8461da7a1d4b47190a01fa6eae219be40aacffab0dd64af7259b2d404572c3d9", "blockNumber": "18718011", "contractAddress": "0xae78736cd615f374d3085123a210448e74fc6393 ", "from": "0xfac5ddb4e3eb6941a458544bfe2588ee566bd4ff", "network": "ethereum", "nodeId": "WyJ0cmFuc2ZlcnMiLDU4Nzld", "to": "0x2201d2400d30bfd8172104b4ad046d019ca4e7bd", "txHash": "0x145c6705ffbf461e85d08b4a7f5850d6b52a7364d93a057722ca1194034f3ba4", "value": "263518859" }, { "blockHash": "0x8461da7a1d4b47190a01fa6eae219be40aacffab0dd64af7259b2d404572c3d9", "blockNumber": "18718011", "contractAddress": "0xae78736cd615f374d3085123a210448e74fc6393 ", "from": "0xe4f719c11fc5ab883e32068df99962985645e860", "network": "ethereum", "nodeId": "WyJ0cmFuc2ZlcnMiLDU4ODBd", "to": "0xc5c2dd38d29960e7bb015e77be44aefbb08f192b", "txHash": "0x145c6705ffbf461e85d08b4a7f5850d6b52a7364d93a057722ca1194034f3ba4", "value": "19152486233394367" }, { "blockHash": "0x8461da7a1d4b47190a01fa6eae219be40aacffab0dd64af7259b2d404572c3d9", "blockNumber": "18718011", "contractAddress": "0xae78736cd615f374d3085123a210448e74fc6393 ", "from": "0xc5c2dd38d29960e7bb015e77be44aefbb08f192b", "network": "ethereum", "nodeId": "WyJ0cmFuc2ZlcnMiLDU4ODFd", "to": "0x882a41fd4c5d09d01900db378903c5c00cc31d64", "txHash": "0x145c6705ffbf461e85d08b4a7f5850d6b52a7364d93a057722ca1194034f3ba4", "value": "19159007520480803" }, { "blockHash": "0x8461da7a1d4b47190a01fa6eae219be40aacffab0dd64af7259b2d404572c3d9", "blockNumber": "18718011", "contractAddress": "0xae78736cd615f374d3085123a210448e74fc6393 ", "from": "0x882a41fd4c5d09d01900db378903c5c00cc31d64", "network": "ethereum", "nodeId": "WyJ0cmFuc2ZlcnMiLDU4ODJd", "to": "0x2201d2400d30bfd8172104b4ad046d019ca4e7bd", "txHash": "0x145c6705ffbf461e85d08b4a7f5850d6b52a7364d93a057722ca1194034f3ba4", "value": "19159007520480803" }, { "blockHash": "0x8461da7a1d4b47190a01fa6eae219be40aacffab0dd64af7259b2d404572c3d9", "blockNumber": "18718011", "contractAddress": "0xae78736cd615f374d3085123a210448e74fc6393 ", "from": "0x882a41fd4c5d09d01900db378903c5c00cc31d64", "network": "ethereum", "nodeId": "WyJ0cmFuc2ZlcnMiLDU4ODNd", "to": "0xc5c2dd38d29960e7bb015e77be44aefbb08f192b", "txHash": "0x145c6705ffbf461e85d08b4a7f5850d6b52a7364d93a057722ca1194034f3ba4", "value": "0" } ], "pageInfo": { "endCursor": "WyJibG9ja19udW1iZXJfZGVzYyIsWzE4NzE4MDExLDU4ODNdXQ==", "hasNextPage": true, "hasPreviousPage": false, "startCursor": "WyJibG9ja19udW1iZXJfZGVzYyIsWzE4NzE4MDExLDU4NzldXQ==" } } } } ``` -------------------------------- ### Enable Multiple Storage Providers (PostgreSQL and CSV) Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/yaml-config/storage.mdx Configure multiple storage providers simultaneously by defining separate configurations for each within the 'storage' section. This example enables both PostgreSQL and CSV storage. ```yaml name: rETHIndexer description: My first rindexer project repository: https://github.com/joshstevens19/rindexer project_type: no-code networks: - name: ethereum chain_id: 1 rpc: https://mainnet.gateway.tenderly.co storage: // [!code focus] postgres: // [!code focus] enabled: true // [!code focus] csv: // [!code focus] enabled: true // [!code focus] ``` -------------------------------- ### Run eRPC with Docker Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/references/rpc-node-providers.mdx Execute the eRPC Docker image, mounting your configuration file and exposing necessary ports. This command starts the eRPC service with your specified settings. ```bash docker run -v $(pwd)/erpc.yaml:/root/erpc.yaml -p 4000:4000 -p 4001:4001 ghcr.io/erpc/erpc:latest ``` -------------------------------- ### Install rindexer CLI (Specific Version) Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/introduction/installation.mdx Installs a specific version of the rindexer CLI. Replace with the desired version. Ensure you are using Git BASH or WSL on Windows. ```bash curl -L https://rindexer.xyz/install.sh | bash -s -- --version ``` -------------------------------- ### Get Application URL and Port-Forward Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/deploying/aws.mdx These commands retrieve the application's pod name and container port, then set up port-forwarding to access the application locally. ```bash export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=rindexer,app.kubernetes.io/instance=rindexer" -o jsonpath="{.items[0].metadata.name}") export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT ``` -------------------------------- ### YAML Configuration for Live Data Indexing Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/yaml-config/index.mdx This YAML configuration is for indexing contract events live as they are produced. It omits start and end blocks, ensuring that the indexer monitors and processes all new blocks from the moment it starts. ```yaml name: rETHIndexer description: My first rindexer project repository: https://github.com/joshstevens19/rindexer project_type: no-code networks: - name: ethereum chain_id: 1 rpc: https://mainnet.gateway.tenderly.co storage: postgres: enabled: true contracts: - name: RocketPoolETH details: - network: ethereum address: "0xae78736cd615f374d3085123a210448e74fc6393" abi: ./abis/RocketTokenRETH.abi.json include_events: - Transfer - Approval ``` -------------------------------- ### Uninstall rindexer Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/introduction/installation.mdx Removes the rindexer installation from your system. ```bash rindexerdown ``` -------------------------------- ### Deploy Phantom Contract CLI Command Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/phantom.mdx Use this command to initiate the deployment of a phantom contract. Replace `` and `` with your specific values. ```bash rindexer phantom deploy --contract-name --network ``` -------------------------------- ### Configure Contract with Start Block Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/yaml-config/contracts.mdx This YAML configuration sets up the 'RocketPoolETH' contract and specifies a `start_block` to begin indexing from a particular block number. This is useful for historical data retrieval. ```yaml name: rETHIndexer description: My first rindexer project repository: https://github.com/joshstevens19/rindexer project_type: no-code networks: - name: ethereum chain_id: 1 rpc: https://mainnet.gateway.tenderly.co storage: postgres: enabled: true contracts: - name: RocketPoolETH details: - network: ethereum address: "0xae78736cd615f374d3085123a210448e74fc6393" start_block: 18600000 ``` -------------------------------- ### Result Limits Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/accessing-data/graphql.mdx You can define how many results you wish to return using the `first` and `last` properties. You cannot return more than 1000 items in a single query, but you can use `offset` to get the item you wish to get. We advise to always set a limit on the amount of items you wish to return. ```APIDOC ## Querying with 'first' ### Description Returns the first N items. ### GraphQL Operation ```graphql query AllTransfers { allTransfers(first: 20) { nodes { blockHash blockNumber contractAddress from network nodeId to txHash value } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } } } ``` ``` ```APIDOC ## Querying with 'last' ### Description Returns the last N items. ### GraphQL Operation ```graphql query AllTransfers { allTransfers(last: 20) { nodes { blockHash blockNumber contractAddress from network nodeId to txHash value } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } } } ``` ``` ```APIDOC ## Querying with 'offset' ### Description Returns N items after skipping M items. ### GraphQL Operation ```graphql query AllTransfers { allTransfers(first: 20, offset: 20) { nodes { blockHash blockNumber contractAddress from network nodeId to txHash value } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } } } ``` ``` -------------------------------- ### Upgrade rindexer Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/introduction/installation.mdx Updates the rindexer installation to the latest available version. ```bash rindexerup ``` -------------------------------- ### Connect to PostgreSQL with PSQL Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/accessing-data/direct-sql.mdx Use this command to establish a connection to your PostgreSQL database via the PSQL command-line tool. Ensure you replace placeholders with your actual database credentials and connection details. ```bash psql 'postgresql://username:password@localhost:5432/your_database' ``` -------------------------------- ### Run Rindexer Project with Docker and Cargo Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/rust-project-deep-dive/indexers.mdx Instructions for running the Rindexer project. First, start the Docker Compose stack for PostgreSQL, then use Cargo to run the application with different command-line flags. ```bash docker compose up -d ``` ```bash cargo run ``` ```bash cargo run -- --indexer ``` ```bash cargo run -- --graphql ``` -------------------------------- ### Ordering Transfers Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/accessing-data/graphql.mdx This example demonstrates how to order transfer results by block number in ascending order. ```APIDOC ## Ordering Transfers ### Description This query retrieves the first 20 transfers, ordered by their block number in ascending order. ### Query ```graphql query AllTransfers { allTransfers(first: 20, orderBy: [BLOCK_NUMBER_ASC]) { nodes { blockHash blockNumber contractAddress from network nodeId to txHash value } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } } } ``` ``` -------------------------------- ### Query Data with SQL in PSQL Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/accessing-data/direct-sql.mdx Once connected to the database via PSQL, you can execute standard SQL queries to retrieve data. This example shows how to select all data from a specific table. ```sql SELECT * FROM my_project_rocket_pool_eth.transfer; ``` -------------------------------- ### Generate GraphQL Queries Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/codegen.mdx Run this command to generate prebuilt GraphQL queries in a 'queries' folder. By default, it targets 'http://localhost:3001'. ```bash rindexer codegen graphql ``` -------------------------------- ### Querying All Transfers (Parameterized) Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/accessing-data/graphql.mdx Example of a GraphQL query to fetch all transfers where the 'first' parameter is passed in. ```APIDOC ## Query AllTransfers (Parameterized) ### Description Fetches a list of all transfers with a dynamic limit specified by a variable. ### Query query AllTransfers($first: Int!) { allTransfers(first: $first) { nodes { blockHash blockNumber contractAddress from network nodeId to txHash value } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } } } ``` -------------------------------- ### Login to Railway CLI Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/deploying/railway.mdx Authenticate with the Railway CLI. Ensure you have the Railway CLI installed before running this command. ```bash railway login ``` -------------------------------- ### Filtering by Block Number Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/accessing-data/graphql.mdx This example shows how to filter transfer events based on a specific block number. ```APIDOC ## Filtering by Block Number ### Description This query retrieves the first 20 transfers that occurred on a specific block number. The `blockNumber` is provided as a string. ### Query ```graphql query AllTransfers { allTransfers(first: 20, condition: { blockNumber: "18600181" }) { nodes { blockHash blockNumber contractAddress from network nodeId to txHash value } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } } } ``` ``` -------------------------------- ### Rindexer Rust Project Main Function Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/rust-project-deep-dive/indexers.mdx This is the main entry point for a Rindexer Rust project. It parses command-line arguments to enable or disable the indexer and GraphQL server, and optionally set the GraphQL port. It then starts the Rindexer service. ```rust use std::env; use self::rindexer_lib::indexers::all_handlers::register_all_handlers; use rindexer::{ event::callback_registry::TraceCallbackRegistry, start_rindexer, GraphQLServerDetails, GraphQLServerSettings, IndexingDetails, StartDetails, }; mod rindexer_lib; #[tokio::main] async fn main() { let args: Vec = env::args().collect(); let mut enable_graphql = false; let mut enable_indexer = false; let mut port: Option = None; for arg in args.iter() { match arg.as_str() { "--graphql" => enable_graphql = true, "--indexer" => enable_indexer = true, _ if arg.starts_with("--port=") || arg.starts_with("--p") => { if let Some(value) = arg.split('=').nth(1) { let overridden_port = value.parse::(); match overridden_port { Ok(overridden_port) => port = Some(overridden_port), Err(_) => { println!("Invalid port number"); return; } } } } _ => {} } } let path = env::current_dir(); match path { Ok(path) => { let manifest_path = path.join("rindexer.yaml"); let result = start_rindexer(StartDetails { manifest_path: &manifest_path, indexing_details: if enable_indexer { Some(IndexingDetails { registry: register_all_handlers(&manifest_path).await, trace_registry: TraceCallbackRegistry::new(), event_stream: None, }) } else { None }, graphql_details: GraphqlOverrideSettings { enabled: enable_graphql, override_port: port, }, cron_scheduler_handle: None, watch: false, }) .await; match result { Ok(_) => {} // Success, do nothing Err(e) => { println!("Error starting rindexer: {:?}", e); } } } Err(e) => { println!("Error getting current directory: {:?}", e); } } } ``` -------------------------------- ### Array Equality Check Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/chatbots/twilio.mdx Example of comparing an array parameter against a raw JSON string representation of an array. ```plaintext array_param == '["raw_json_array_string"]' ``` -------------------------------- ### Set Project Description Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/start-building/yaml-config/top-level-fields.mdx The `description` field provides a brief description of the project. This field is optional. ```yaml name: rETHIndexer description: My first rindexer project ``` -------------------------------- ### Querying All Transfers (Hardcoded Parameter) Source: https://github.com/joshstevens19/rindexer/blob/master/documentation/docs/pages/docs/accessing-data/graphql.mdx Example of a GraphQL query to fetch all transfers with a hardcoded 'first' parameter. ```APIDOC ## Query AllTransfers (Hardcoded Parameter) ### Description Fetches a list of all transfers with a specified limit. ### Query query AllTransfers { allTransfers(first: 20) { nodes { blockHash blockNumber contractAddress from network nodeId to txHash value } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } } } ```