# LastActivity

**Slug:** `last-activity`  
**Import:** `import { LastActivity } from "@p4n/erc8004-ui"`

> **NOTE — unofficial library.** `@p4n/erc8004-ui` is an independent, community-built project. It is not affiliated with, maintained by, or endorsed by the authors of ERC-8004. It reads the standard's on-chain data through public subgraphs; it does not speak for the standard.

## Description

Cross-registry relative timestamp showing when the agent was last active (e.g. "Active 3 hours ago"). Reflects the most recent event across all registries.

## Usage

```tsx
import { LastActivity } from "@p4n/erc8004-ui"
<LastActivity agentRegistry="eip155:8453:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432" agentId={888} />
```

## Examples

### Inside AgentProvider

Renders the last activity timestamp without repeating identity props.

```tsx
<AgentProvider agentRegistry="eip155:8453:0x8004...a432" agentId={888}>
  <LastActivity />
</AgentProvider>
```

### As Status Indicator

Combine with a live dot and muted styling to show agent presence in a header.

```tsx
<div className="flex items-center gap-2 text-xs text-erc8004-muted-fg">
  <span className="h-1.5 w-1.5 rounded-full bg-erc8004-positive" />
  <LastActivity agentRegistry="eip155:8453:0x8004...a432" agentId={888} />
</div>
```

## In Context

LastActivity in a sidebar showing agent status alongside the activity log.

```tsx
<AgentProvider agentRegistry="eip155:8453:0x8004...a432" agentId={888}>
  <div className="flex items-center gap-3">
    <AgentName />
    <LastActivity />
  </div>
  <ActivityLog pageSize={5} />
</AgentProvider>
```

## API Reference

| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `agentRegistry` | `string` | no | — | Agent registry in the format "eip155:{chainId}:{contractAddress}". Required unless inside an <AgentProvider>. |
| `agentId` | `number` | no | — | ERC-721 token ID of the agent. Required unless inside an <AgentProvider>. |
| `className` | `string` | no | — | Optional CSS classes merged onto the component root for layout, spacing, or custom styling (e.g. Tailwind). |

## States

This component handles loading and error states internally with inline placeholders. No configuration needed.

## Reference

- Live preview & full docs: https://erc8004-ui.vercel.app/docs/components/last-activity
- Markdown source: https://erc8004-ui.vercel.app/docs/components/last-activity.md
