@sentio/ui-web3
v0.1.0
Published
A Web3-focused UI component library for displaying blockchain transactions and address information.
Downloads
38
Keywords
Readme
@sentio/ui-web3
A Web3-focused UI component library for displaying blockchain transactions and address information.
Features
- 🔗 Full set of Web3 transaction components
- 💰 Display balance changes
- 🏷️ Address labels and name resolution
- 📊 Chain data visualization
- ♻️ Reuses styles and components from
@sentio/ui-core
Installation
pnpm add @sentio/ui-web3 @sentio/ui-coreNote: This package depends on @sentio/ui-core and re-exports all of its contents, so you can import everything from @sentio/ui-web3 if preferred.
Usage
// Includes both ui-core and ui-web3 components
import {
Button, // from ui-core
BarLoading, // from ui-core
BalanceChanges, // from ui-web3
HexNumber, // from ui-web3
TransactionStatus // from ui-web3
} from '@sentio/ui-web3'
import '@sentio/ui-core/dist/style.css'
function TransactionView({ transaction, block }) {
return (
<div>
<TransactionStatus status={transaction.status} />
<BalanceChanges transaction={transaction} block={block} />
<HexNumber data={transaction.hash} />
</div>
)
}Web3 Components
Transaction Components
BalanceChanges- Display balance changes in transactionsHexNumber- Hex number/address display with link and copyTransactionStatus- Transaction status indicatorTransactionValue- Transaction value displayAddressFrom- Source address displayAddressTo- Destination address displayTransactionLabel- Transaction label componentTransactionColumns- Transaction table columnsTransactionBrief- Brief transaction summarySimulatorInfo- Transaction simulation information
Call Trace Components
FlatCallTraceTree- Flat call trace tree visualizationCallTreeNode- Individual call tree nodeLocationViewer- Source code location viewerLocationStatus- Location status indicatorisLocationStatus()- Check if value is a location statusForwardDef- Forward definition component
Fund Flow Components
TransactionFundflow- Transaction fund flow visualizationFundFlow- Fund flow diagramVizGraph- Graphviz-based graph visualizationprocessDecodedCallTrace()- Process decoded call tracesgenerateNodesAndEdges()- Generate graph nodes and edgesexportSVG()- Export fund flow as SVGexportPNG()- Export fund flow as PNG
MEV Components
MevInfo- MEV (Maximal Extractable Value) information displayMevType- MEV type indicatorsMevLink- MEV-related linksSandwichTxns- Sandwich attack transaction displayFlashbotIcon- Flashbot icon component
Simulator Components
NewSimulation- Transaction simulation interfaceFunctionParameter- Function parameter inputFunctionSelect- Function selector dropdownAmountUnitSelect- Amount unit selector (Wei, Gwei, Ether, etc.)DisclosurePanel- Collapsible panel for simulatorSimulatorProvider- Simulator context provideruseSimulatorContext()- Access simulator contextgenCoefficient()- Generate unit coefficientgetWeiAmount()- Convert to Wei amount
Editor Components
SourceStore- Source code storageSoliditySourceParser- Solidity source parserSentioDocumentSymbolProvider- Document symbol provider for MonacoSentioDefinitionProvider- Go-to-definition providerSentioHoverProvider- Hover information providerSentioImplementationProvider- Implementation providerSentioReferenceProvider- Reference providerSourceView- Source code viewerHoverContextWidget- Hover context widgetSourceSymbols- Source symbols displaySymbolIcons- Symbol type iconsSourceTree- Source tree navigationsetSolidityLanguage()- Configure Solidity languagesetSolidityProviders()- Set Solidity providersopenCodeEditor()- Open code in editorsentioTheme- Monaco editor themesolidityLanguageConfig- Solidity language configurationsolidityTokensProvider- Solidity syntax tokensmoveLanguageConfig- Move language configurationmoveTokenProvider- Move language tokens
Web3 Utilities & Hooks
useAddressTag()- Fetch address tag informationusePrice()- Fetch token price informationuseFallbackName()- Get fallback contract nameparseUri()- Parse debug URIstrackEvent()- Track analytics eventssetTrackingHandler()- Set custom tracking handlergetNativeToken()- Get native token for chain- Transaction helper utilities
- EtherLink components and utilities
- Transaction context providers
Types & Interfaces
- Transaction types (
SimulationData,BlockOverride,StateOverride) - Transfer types (
TransferItem) - MEV types (
MevData,Token,Trader,Revenue,ArbitrageResult,SandwichResult,SandwichTx) - Simulator types (
SimulationFormType,Contract,AbiFunction,AbiInput,FunctionParam,AccessListItem,StateOverrideItem,SourceOverrideItem,Simulation,SimulateTransactionRequest,SimulateTransactionResponse,AmountUnit,SimulationFormState,ContractSelectType) - Editor types (
TextOccurrence,TreeNode,PreviewLocation,FetchAndCompileResponse,CompilerType,SymbolKind)
Re-exported from @sentio/ui-core
All components and utilities from @sentio/ui-core are re-exported, including:
- Common components (Button, Dialog, Tooltip, Loading, Input, Select, Switch, etc.)
- Table components (ResizeTable, Icons)
- Menu components (PopupMenuButton, MenuItem, SubMenuButton)
- Tree components (FlatTree)
- Utilities (useMobile, useBoolean, classNames, number formatting)
Using ui-core alone
If your project doesn't need Web3 functionality, you can install and use just @sentio/ui-core:
pnpm add @sentio/ui-coreimport { Button, BaseDialog, BarLoading } from '@sentio/ui-core'
import '@sentio/ui-core/dist/style.css'Architecture
@sentio/ui-web3
↓ depends on & re-exports
@sentio/ui-core
↓ provides
Core components + stylesUsers can:
- Install only
@sentio/ui-core— get core UI components. - Install
@sentio/ui-web3— automatically includesui-coreplus Web3 components.
Development
Component Development with Ladle
This package uses Ladle for component development and testing. Ladle provides a fast, lightweight alternative to Storybook for developing React components in isolation.
Prerequisites
Make sure you have dependencies installed:
pnpm installStarting the Development Server
To start the Ladle development server:
pnpm ladle serveThis will:
- Start a local development server (typically at
http://localhost:61000) - Watch for changes in your component stories
- Provide hot module replacement for fast development
- Display all your Web3 and core component stories in an interactive UI
Writing Stories
Stories are located alongside components with the .stories.tsx extension. For example:
// src/transaction/HexNumber.stories.tsx
import type { Story } from '@ladle/react'
import { HexNumber } from './HexNumber'
export const Default: Story = () => (
<HexNumber data="0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb" />
)
export const WithCopy: Story = () => (
<HexNumber
data="0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
enableCopy
/>
)Available Story Examples
Check out existing stories in the src/ directory:
src/transaction/HexNumber.stories.tsx- Hex number display examplessrc/transaction/BalanceChanges.stories.tsx- Balance changes visualizationsrc/transaction/TransactionComponents.stories.tsx- Transaction component examplessrc/transaction/SimulatorInfo.stories.tsx- Simulator info examplessrc/transaction/TransactionBrief.stories.tsx- Transaction brief displaysrc/transaction/calltrace/FlatCallTrace.stories.tsx- Call trace examplessrc/transaction/fundflow/NewFundflow.stories.tsx- Fund flow visualizationsrc/simulator/NewSimulation.stories.tsx- Transaction simulatorsrc/mev/MevInfo.stories.tsx- MEV information displaysrc/editor/Editor.stories.tsx- Code editor examples- And more...
Building for Production
To build the package:
pnpm buildThis will:
- Build CSS with Tailwind (
pnpm build:css) - Build JavaScript/TypeScript with tsup (
pnpm build:js)
Watch Mode for Development
If you're developing this package alongside another package:
pnpm devThis runs both CSS and JS builds in watch mode concurrently.
Testing with Real Data
Many Web3 components require blockchain data. When developing stories:
- Use mock data structures that match the expected interfaces
- Consider using real transaction hashes for testing (see existing stories)
- The simulator components can work with test ABIs and contracts
- Call trace and fund flow components accept decoded transaction data
