Skip to content

Kmino-io/explain

Repository files navigation

Sui Transaction Explainer

A beautiful, user-friendly web application that translates complex Sui blockchain transactions into plain, human-readable language. Simply paste a transaction digest or explorer link, and get a clear explanation of what happened, including object changes, transfers, gas usage, and smart contract calls.

Sui Transaction Explainer

✨ Features

Core Functionality

  • Transaction Parsing: Fetch and parse any Sui transaction by digest
  • Human-Readable Summaries: Clear explanations like "Alice sends 249.50 USDC to Bob"
  • Token Support: Displays all token transfers (USDC, USDT, WETH, etc.) with real logos
  • NFT Recognition: Automatically detects and displays NFTs with preview images
  • Object Tracking: See all objects that were created, modified, transferred, or deleted
  • Gas Analytics: Precise gas usage breakdown in SUI
  • Smart Contract Calls: Identify which Move functions were called and from which packages

User Experience

  • Flexible Input: Accept transaction digests or full explorer URLs (SuiScan, SuiVision, Sui Explorer)
  • Visual Flow Diagrams: See transfer flows with animated arrows showing sender β†’ recipient
  • Token Icons: Real token logos from CoinGecko for all major cryptocurrencies
  • NFT Previews: Hover over NFTs to see images and metadata, click to open in explorer
  • Interactive Elements: Clickable user addresses and objects that open in SuiScan
  • Modern UI: Beautiful gradient design with glassmorphism effects
  • Responsive Design: Works seamlessly on desktop, tablet, and mobile
  • Real-time Status: Loading states and error handling for a smooth experience

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm/yarn
  • A Sui RPC endpoint (defaults to Sui mainnet)

Installation

  1. Clone the repository
git clone <repository-url>
cd explain
  1. Install dependencies
npm install
  1. Start the development server
npm run dev
  1. Open your browser Navigate to http://localhost:5173

Building for Production

npm run build
npm run preview

πŸ“– Usage

Basic Usage

  1. Get a Transaction Digest: Find any Sui transaction on an explorer or from your wallet
  2. Paste into the App: Either paste the full URL or just the transaction digest
  3. Click "Explain": The app fetches and parses the transaction
  4. Read the Results: Get a plain-language explanation of what happened

Example Transactions

Try these real transactions from Sui mainnet:

# USDC Transfer (249.50 USDC)
AoLRL9ix8BY2AZYFpPPsXCkAAia3CqHCYoBwmFjBy8Bu

# NFT Creation (4 Swarm Network Agent NFTs)
2NbyGSNjmqqxC6tHTz49Rb6JXQ4hh2fC2LTvf7yUrgPh

Or paste any transaction hash or URL from SuiScan/Sui Explorer!

Supported Explorer URLs

The app can extract transaction digests from:

  • SuiScan: https://suiscan.xyz/mainnet/tx/[digest]
  • SuiVision: https://suivision.xyz/txblock/[digest]
  • Sui Explorer: https://explorer.sui.io/txblock/[digest]

πŸ—οΈ Architecture

Tech Stack

  • Frontend: React 18 + TypeScript
  • Build Tool: Vite for fast development and optimized production builds
  • Styling: Tailwind CSS with custom Sui-themed colors
  • Icons: Lucide React for beautiful, consistent icons
  • Blockchain: @mysten/sui.js SDK for Sui blockchain interaction

Project Structure

explain/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”‚   β”œβ”€β”€ TransactionInput.tsx       # Input form for transaction digest
β”‚   β”‚   β”œβ”€β”€ TransactionDisplay.tsx     # Main display component
β”‚   β”‚   └── TransactionVisualization.tsx  # Flow visualization
β”‚   β”œβ”€β”€ services/            # Business logic
β”‚   β”‚   └── suiService.ts    # Sui RPC client and parsers
β”‚   β”œβ”€β”€ types/               # TypeScript type definitions
β”‚   β”‚   └── transaction.ts   # Transaction data structures
β”‚   β”œβ”€β”€ App.tsx              # Main app component
β”‚   β”œβ”€β”€ main.tsx             # App entry point
β”‚   └── index.css            # Global styles
β”œβ”€β”€ public/                  # Static assets
β”œβ”€β”€ index.html              # HTML template
β”œβ”€β”€ package.json            # Dependencies and scripts
β”œβ”€β”€ tailwind.config.js      # Tailwind configuration
β”œβ”€β”€ tsconfig.json           # TypeScript configuration
└── vite.config.ts          # Vite configuration

Data Flow

  1. User Input β†’ User enters transaction digest
  2. RPC Fetch β†’ App calls Sui RPC via @mysten/sui.js
  3. Parsing β†’ Transaction data is parsed into structured format
  4. Summary Generation β†’ Human-readable summaries are generated
  5. Display β†’ Components render the parsed data with visualizations

For more architectural details, see ARCHITECTURE.md

πŸ”§ Configuration

Switching Networks

By default, the app connects to Sui mainnet. To use testnet or devnet, edit src/services/suiService.ts:

// Change 'mainnet' to 'testnet' or 'devnet'
const client = new SuiClient({ url: getFullnodeUrl('testnet') })

Custom RPC Endpoint

To use a custom RPC endpoint:

const client = new SuiClient({ url: 'https://your-custom-rpc.com' })

🎨 Customization

Styling

The app uses Tailwind CSS with custom Sui colors defined in tailwind.config.js:

colors: {
  'sui-blue': '#4DA2FF',
  'sui-dark': '#1A1B1F',
}

Adding Features

The codebase is designed to be extensible:

  • New Summary Rules: Add logic in generateSummary() in suiService.ts
  • Custom Visualizations: Create new components in src/components/
  • Enhanced Parsing: Extend the parseTransaction() function
  • Token Icons: Add new token logos in TokenIcon.tsx (uses CoinGecko CDN)
  • Token Mappings: Add token addresses in suiService.ts (see TOKEN_MAPPINGS.md)

πŸ§ͺ Development

Code Quality

# Type checking
npm run build

# Linting (if configured)
npm run lint

Testing

Test the app with various transaction types:

  • Simple SUI transfers
  • NFT minting and transfers
  • Complex DeFi transactions
  • Failed transactions
  • Transactions with many object changes

πŸ“Š API Reference

SuiService

The main service for interacting with the Sui blockchain.

fetchTransactionDetails(digest: string): Promise<ParsedTransaction>

Fetches and parses a transaction by its digest.

Parameters:

  • digest (string): The transaction digest hash

Returns:

  • Promise resolving to a ParsedTransaction object

Throws:

  • Error if transaction cannot be fetched or parsed

Type Definitions

See src/types/transaction.ts for complete type definitions:

  • ParsedTransaction: Main transaction data structure
  • ObjectChange: Represents object creation, mutation, or deletion
  • TransferChange: Represents object transfers
  • PackageCall: Represents smart contract function calls

🀝 Contributing

Contributions are welcome! Here are some ideas:

  • Add support for more transaction types
  • Improve summary generation with more patterns
  • Add transaction comparison features
  • Create shareable transaction reports
  • Add transaction history tracking

πŸ“ License

MIT License - feel free to use this project for any purpose.

πŸ”— Resources

πŸ› Troubleshooting

Common Issues

"Failed to fetch transaction"

  • Check that the transaction digest is valid
  • Ensure you have internet connectivity
  • Verify the RPC endpoint is accessible

Slow Loading

  • Some transactions with many operations may take longer to parse
  • Consider implementing caching for repeated queries

Type Errors

  • Sui transaction structures may vary; the parser handles most common cases
  • Unknown object types will display as "Object"

πŸ“§ Support

For questions or issues, please open a GitHub issue or reach out to the maintainers.


Built with ❀️ for the Sui community

About

what Is that transaction you ask? I have the answer for you!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages