blocktorch
  • Overview
    • Introduction
    • Install/Setup
    • Quickstart
  • Concepts
    • Data Sources
      • EVM Chains
      • Roll-ups
      • Local forks
        • Setup Hardhat fork
        • Setup managed Hardhat Fork
        • Hardhat forking API
      • Smart Contracts
        • Adding smart contracts
      • Custom Event Data
      • Oracles
      • Account Abstraction modules
        • Navigating the AA Explorer
      • Decentralized Datastorage
      • React Frontends
    • Querying data
    • Telemetry
  • Use cases
    • Searching
      • Logs
        • Log Details
      • Sharing search results
    • Monitoring
      • Building monitors
      • Alerting
    • Tracing
      • Stack traces
      • End-2-End Traces
    • Dashboarding
      • Pre-made dashboards
      • Custom graphs
    • Collaborating
      • Inviting others
      • Sharing data
    • Debugging
      • Step debugger
    • Benchmarking
    • Managing incidents
      • Troubelshooting
      • Post mortem
    • Predicting
  • Ressources
    • Demo videos
    • FAQs
  • Contribute
    • Open Source projects
Powered by GitBook
On this page
  • Why consider using Dragon?
  • Installation
  • Usage
  • Accessing data collected by Dragon
  1. Concepts
  2. Data Sources

React Frontends

PreviousDecentralized DatastorageNextQuerying data

Last updated 1 year ago

Transactions that fail in the client/frontend cannot be found in a block explorer as the transaction never makes it into the mempool and subsequently on chain. For that reason, the Blocktorch team developed , an SDK that can easily be added to dApp frontends utilizing .

With Dragon you can track failing and successful web3 client transactions for as well as analytics.

Why consider using Dragon?

  • json RPC responses, especially error messages, in the UI are cryptic

  • to understand whether errors impacting users are a bug in the frontend or the smart contract

  • to get better analytics about the wallets interacting with your dApp

  • to understand if wallets are interacting with your smart contracts through your dApp frontend or through their own scripts, which can especially be helpful for security

Installation

npm install @blocktorch/0xdragon

or if you prefer yarn

yarn add @blocktorch/0xdragon

Usage

SDK initialization

import { Dragon } from '@blocktorch/0xdragon'
const dragon = new Dragon({
	projectId: <your-project-id>,
	apiKey: <your-blocktorch-api-key>
})

In the constructor you can also specify additional options:

  • contractName (string) - default identifier for what the transactions are interacting with. Default is "unknown"

  • chainId (number) - chain ID of the application

  • http (object):

    • maxRetries (number) - number of times failed SDK requests are retried

    • delay (number) - number of times failed SDK requests are retried

    • exponentialBackoff (boolean) - Whether to allow exponential backoff or not

init(options?)

Initialize the tracking of a single transaction

const id = dragon.init()

You can override options per transaction.

  • contract (string) - identifier for what the transaction is interacting with

  • chainId (number) - id of the blockchain

success(id, transaction)

Track the transaction as a success. Should be done after the transaction is accepted on chain.

await dragon.success(id, transaction)

error(id, error)

Track the transaction as an error

await dragon.error(id, error)

wrap(fn, options?)

If you are using ethers@5 or any other compatible libraries you can use a helper function to wrap your whole transaction and it will detect success or failure itself. It will wait until the transaction receipt is received to mark it as a success.

await dragon.wrap(
   contract.doSmth({ value:  ethers.utils.parseEther("0.1") })
)

You can also specify the following options:

  • contract (string) - identifier for what the transaction is interacting with

  • chainId (number) - id of the blockchain

Accessing data collected by Dragon

You can get your project ID and api key from the on the "Settings" page

All dragon data can be queried for as well as when logs. For successful transactions we automatically contextualize your transaction logs with dragon data to show the full

Dragon
React
debugging
Blocktorch app
monitoring
searching
end-2-end trace