### Build and Start Production Server Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md Builds the application for production deployment and then starts the production server. ```bash pnpm build && pnpm start ``` -------------------------------- ### Install Project Dependencies with pnpm Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md Installs all required project dependencies using the pnpm package manager. ```bash pnpm install ``` -------------------------------- ### Create a Custom Endpoint with Access and Source Layers Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md Demonstrates how to register a new GET endpoint using the `Access` layer, define request parameters with Zod validation, handle custom errors, query blockchain transactions using the `Source` layer, and transform the response data. This example fetches transactions for a given contract address on a specified chain. ```typescript const access = new Access(); // ----------------- Register an endpoint ------------------- access.registerEndpoint({ path: "/chains/:chainId/contracts/:address/transactions", method: "get", request: { params: z.object({ chainId: z.string(), address: z.string().refine((val) => /^0x[a-fA-F0-9]{40}$/.test(val), { message: "Invalid EVM address", }), }), }, response: z.object({ data: z.array(z.object({ hash: z.string() })) }), handler: async ({ params }) => { const source = new Source(); if (params.chainId === "mumbai") { // ----------------- You can return custom errors ------------------- throw new BlueprintAccessError("Chain not supported", 400); } // ----------------- Define the query you want to make to Insight ------------------- const transactions = await source.transactions.get(params.chainId, { filters: { to_address: params.address, }, orderBy: { field: ["block_number"], direction: "desc", }, pagination: { limit: 10, }, }); // ----------------- Do any data transformations you'd like and return a response ------------------- return { data: transactions.data.map((tx) => ({ hash: tx.hash })) }; }, }); // ----------------- Start the server ------------------- access.start(); ``` -------------------------------- ### Run Development Server Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md Starts the development server for the Insight Blueprint application, typically with hot-reloading and debugging features. ```bash pnpm dev ``` -------------------------------- ### Clone Insight Blueprint Starter Repository Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md Clones the thirdweb Insight Blueprint Starter repository from GitHub and navigates into the project directory. ```bash git clone https://github.com/thirdweb-example/insight-blueprint-starter cd insight-blueprint-starter ``` -------------------------------- ### Run Test Suite Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md Executes the project's test suite to verify functionality and ensure code quality. ```bash pnpm test ``` -------------------------------- ### Register a Basic Endpoint with Access Layer Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md Illustrates the fundamental process of registering a new HTTP endpoint (`/my-endpoint`) using the `Access` layer. It shows how to define the path, HTTP method, request query parameters with Zod, and the expected response structure. ```typescript const app = new Access(); app.registerEndpoint({ path: "/my-endpoint", method: "get", request: { query: z.object({ address: z.string(), }), }, response: z.object({ data: z.array(z.any()), }), handler: async ({ query }) => { // Your endpoint logic here return { data: [] }; }, }); ``` -------------------------------- ### Query Blockchain Data Using Source Layer Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md Shows how to use the `Source` layer to fetch blockchain events and transactions. It demonstrates filtering by address, block number, and pagination for events, and filtering by `from_address` for transactions across different chains. ```typescript const source = new Source(); // Fetch events const events = await source.events.get("ethereum", { filters: { address: "0x...", block_number: { operator: "gte", value: 1000000 } }, pagination: { limit: 100 } }); // Fetch transactions const txs = await source.transactions.get("polygon", { filters: { from_address: "0x..." } }); ``` -------------------------------- ### Configure thirdweb Client ID Environment Variable Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md Sets the `THIRDWEB_CLIENT_ID` environment variable with your thirdweb API key. This key is essential for authenticating with thirdweb services. ```bash THIRDWEB_CLIENT_ID=your_api_key ``` -------------------------------- ### Implement a Custom Data Transformation Class in TypeScript Source: https://github.com/thirdweb-dev/insight-blueprint-starter/blob/main/README.md This snippet demonstrates how to define a custom data transformation class in TypeScript. It shows the basic structure of a class implementing the `Transformation` interface, requiring an asynchronous `transform` method to process `SourceData` into `ResultData`. ```typescript class MyTransformation implements Transformation { async transform(data: SourceData): Promise { // Transform the data return transformedData; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.