> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstream.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 區塊與交易

> Blocks、Transactions、Events、Calls 以及其他基礎設施 Cubes 的查詢範例

## 概述

本頁提供區塊鏈基礎設施相關 Cube 的查詢示例 — 涵蓋區塊、交易、智慧合約事件與內部 trace 等基礎資料。

***

## 區塊

### 最新區塊（Solana）

```graphql theme={null}
query {
  Solana {
    Blocks(limit: {count: 10}, orderBy: {descending: Block_Time}) {
      Block {
        Time
        Slot
        Height
        Hash
        ParentSlot
        TxCount
      }
    }
  }
}
```

### 最新區塊（Ethereum）

```graphql theme={null}
query {
  EVM(network: eth) {
    Blocks(limit: {count: 10}, orderBy: {descending: Block_Time}) {
      Block {
        Time
        Number
        Hash
        GasUsed
        GasLimit
        BaseFee
        TxCount
        Coinbase
      }
    }
  }
}
```

***

## 交易

### 按地址查詢近期交易（Solana）

```graphql theme={null}
query {
  Solana {
    Transactions(
      signer: {is: "WALLET_ADDRESS"}
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time Slot }
      Transaction {
        Signature
        Fee
        FeePayer
        Result { Success }
      }
    }
  }
}
```

### 按地址查詢近期交易（EVM）

```graphql theme={null}
query {
  EVM(network: eth) {
    Transactions(
      fromAddress: {is: "0xWALLET_ADDRESS"}
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time Number }
      Transaction {
        Hash
        From
        To
        Value
        Gas
        GasPrice
      }
    }
  }
}
```

***

## 事件（僅 EVM）

### 按合約與 Topic 過濾事件

```graphql theme={null}
query {
  EVM(network: eth) {
    Events(
      contractAddress: {is: "0xCONTRACT_ADDRESS"}
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time Number }
      Transaction { Hash }
      Log {
        SmartContract
        Index
        Signature { Name Signature }
        Data
      }
    }
  }
}
```

### 按事件簽名（Topic0）過濾

```graphql theme={null}
query {
  EVM(network: eth) {
    Events(
      topic0: {is: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"}
      limit: {count: 10}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Transaction { Hash }
      Log { SmartContract Index Data }
    }
  }
}
```

***

## 呼叫 / Trace（僅 EVM）

### 對某合約的內部呼叫

```graphql theme={null}
query {
  EVM(network: eth) {
    Calls(
      toAddress: {is: "0xCONTRACT_ADDRESS"}
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time Number }
      Transaction { Hash }
      Call {
        From
        To
        Opcode
        Value
        Gas
        GasUsed
        Signature { Name }
      }
    }
  }
}
```

***

## 指令（僅 Solana）

### 某程式的近期指令

```graphql theme={null}
query {
  Solana {
    Instructions(
      programId: {is: "PROGRAM_ADDRESS"}
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time Slot }
      Transaction { Signature }
      Instruction {
        Index
        Depth
        Program { Address Name Method }
        Accounts
      }
    }
  }
}
```

***

## 獎勵（僅 Solana）

### 驗證者的質押獎勵

```graphql theme={null}
query {
  Solana {
    Rewards(
      address: {is: "VALIDATOR_ADDRESS"}
      limit: {count: 50}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time Slot }
      Reward {
        Address
        Amount
        AmountInUSD
        PostBalance
        RewardType
        Commission
      }
    }
  }
}
```

***

## 礦工獎勵（僅 EVM）

### 區塊獎勵構成

```graphql theme={null}
query {
  EVM(network: eth) {
    MinerRewards(
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time Number }
      Reward {
        Miner
        TotalReward
        TotalRewardInUSD
        StaticReward
        DynamicReward
        TxFees
        BurntFees
      }
    }
  }
}
```

***

## 相關文件

<CardGroup cols={2}>
  <Card title="資料 Cube" icon="cubes" href="/zh-Hant/graphql/schema/cubes">
    所有 Cube（含 Blocks、Transactions、Events、Calls）的詳細欄位結構。
  </Card>

  <Card title="鏈分組" icon="layer-group" href="/zh-Hant/graphql/schema/chain-groups">
    瞭解 EVM 與 Solana 分別提供哪些 Cube。
  </Card>
</CardGroup>
