> For the complete documentation index, see [llms.txt](https://andrewkimjoseph.gitbook.io/celina-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://andrewkimjoseph.gitbook.io/celina-sdk/services/blockchainservice.md).

# BlockchainService

[**@andrewkimjoseph/celina-sdk**](/celina-sdk/api-reference/api-reference.md)

***

[@andrewkimjoseph/celina-sdk](/celina-sdk/api-reference/api-reference.md) / [services/blockchain.service](https://github.com/andrewkimjoseph/celina-sdk/blob/main/docs/api-reference/services/blockchain.service/README.md) / BlockchainService

## Class: BlockchainService

Defined in: [src/services/blockchain.service.ts:61](https://github.com/andrewkimjoseph/celina-sdk/blob/970ab720c805303ead8b20406c6579ecdcf2193a/src/services/blockchain.service.ts#L61)

Celo mainnet block and transaction queries.

### Constructors

#### Constructor

> **new BlockchainService**(`clientFactory`): `BlockchainService`

Defined in: [src/services/blockchain.service.ts:62](https://github.com/andrewkimjoseph/celina-sdk/blob/970ab720c805303ead8b20406c6579ecdcf2193a/src/services/blockchain.service.ts#L62)

**Parameters**

**clientFactory**

`CeloClientFactory`

**Returns**

`BlockchainService`

### Methods

#### getBlock()

> **getBlock**(`blockId`, `options?`): `Promise`<{ `gasLimit`: `string`; `gasUsed`: `string`; `gasUtilization`: `number`; `hash`: `` `0x${string}` `` | `null`; `miner`: `` `0x${string}` ``; `number`: `string` | `undefined`; `parentHash`: `` `0x${string}` ``; `timestamp`: `string`; `transactionCount`: `number`; `transactions`: (`` `0x${string}` `` | { `blockNumber`: `string` | `undefined`; `from`: `` `0x${string}` ``; `gas`: `string`; `gasPrice`: `string` | `undefined`; `gasPriceGwei`: `number` | `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `nonce`: `number`; `to`: `` `0x${string}` `` | `null`; `transactionIndex`: `number` | `null` | `undefined`; `type`: `string` | `undefined`; `value`: `string`; `valueCelo`: `number`; })\[] | `undefined`; }>

Defined in: [src/services/blockchain.service.ts:91](https://github.com/andrewkimjoseph/celina-sdk/blob/970ab720c805303ead8b20406c6579ecdcf2193a/src/services/blockchain.service.ts#L91)

Fetch a block by number, hash, or tag.

**Parameters**

**blockId**

`string` | `number`

Block number, hash, `latest`, or `pending`

**options?**

**includeTransactions?**

`boolean`

When true, include full transaction objects

**Returns**

`Promise`<{ `gasLimit`: `string`; `gasUsed`: `string`; `gasUtilization`: `number`; `hash`: `` `0x${string}` `` | `null`; `miner`: `` `0x${string}` ``; `number`: `string` | `undefined`; `parentHash`: `` `0x${string}` ``; `timestamp`: `string`; `transactionCount`: `number`; `transactions`: (`` `0x${string}` `` | { `blockNumber`: `string` | `undefined`; `from`: `` `0x${string}` ``; `gas`: `string`; `gasPrice`: `string` | `undefined`; `gasPriceGwei`: `number` | `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `nonce`: `number`; `to`: `` `0x${string}` `` | `null`; `transactionIndex`: `number` | `null` | `undefined`; `type`: `string` | `undefined`; `value`: `string`; `valueCelo`: `number`; })\[] | `undefined`; }>

Block header fields and optional transaction list

**Throws**

When the block is not found

***

#### getLatestBlocks()

> **getLatestBlocks**(`count?`, `offset?`): `Promise`<`object`\[]>

Defined in: [src/services/blockchain.service.ts:151](https://github.com/andrewkimjoseph/celina-sdk/blob/970ab720c805303ead8b20406c6579ecdcf2193a/src/services/blockchain.service.ts#L151)

List recent blocks ending at the chain tip (newest last in the array).

**Parameters**

**count?**

`number` = `5`

Number of blocks to return (1–100, default 5)

**offset?**

`number` = `0`

Skip this many blocks from the tip before collecting

**Returns**

`Promise`<`object`\[]>

Summary fields per block (no full transaction payloads)

***

#### getNetworkStatus()

> **getNetworkStatus**(): `Promise`<{ `blockNumber`: `string`; `chainId`: `number`; `gasPriceWei`: `string`; `network`: `string`; }>

Defined in: [src/services/blockchain.service.ts:68](https://github.com/andrewkimjoseph/celina-sdk/blob/970ab720c805303ead8b20406c6579ecdcf2193a/src/services/blockchain.service.ts#L68)

Celo mainnet chain id, latest block number, and current gas price.

**Returns**

`Promise`<{ `blockNumber`: `string`; `chainId`: `number`; `gasPriceWei`: `string`; `network`: `string`; }>

Network metadata including `chainId`, `blockNumber`, and `gasPriceWei`

***

#### getTransaction()

> **getTransaction**(`hash`): `Promise`<{ `blockNumber`: `string` | `undefined`; `from`: `` `0x${string}` ``; `gas`: `string`; `gasPrice`: `string` | `undefined`; `gasPriceGwei`: `number` | `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `nonce`: `number`; `to`: `` `0x${string}` `` | `null`; `transactionIndex`: `number` | `null` | `undefined`; `type`: `string` | `undefined`; `value`: `string`; `valueCelo`: `number`; } | { `blockNumber`: `string` | `undefined`; `from`: `` `0x${string}` ``; `gas`: `string`; `gasEfficiency`: `number`; `gasPrice`: `string` | `undefined`; `gasPriceGwei`: `number` | `undefined`; `gasUsed`: `string`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `nonce`: `number`; `status?`: `string`; `to`: `` `0x${string}` `` | `null`; `transactionIndex`: `number` | `null` | `undefined`; `type`: `string` | `undefined`; `value`: `string`; `valueCelo`: `number`; }>

Defined in: [src/services/blockchain.service.ts:187](https://github.com/andrewkimjoseph/celina-sdk/blob/970ab720c805303ead8b20406c6579ecdcf2193a/src/services/blockchain.service.ts#L187)

Fetch a transaction and its receipt by hash.

**Parameters**

**hash**

`` `0x${string}` ``

Transaction hash

**Returns**

`Promise`<{ `blockNumber`: `string` | `undefined`; `from`: `` `0x${string}` ``; `gas`: `string`; `gasPrice`: `string` | `undefined`; `gasPriceGwei`: `number` | `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `nonce`: `number`; `to`: `` `0x${string}` `` | `null`; `transactionIndex`: `number` | `null` | `undefined`; `type`: `string` | `undefined`; `value`: `string`; `valueCelo`: `number`; } | { `blockNumber`: `string` | `undefined`; `from`: `` `0x${string}` ``; `gas`: `string`; `gasEfficiency`: `number`; `gasPrice`: `string` | `undefined`; `gasPriceGwei`: `number` | `undefined`; `gasUsed`: `string`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `nonce`: `number`; `status?`: `string`; `to`: `` `0x${string}` `` | `null`; `transactionIndex`: `number` | `null` | `undefined`; `type`: `string` | `undefined`; `value`: `string`; `valueCelo`: `number`; }>

Transaction fields, gas efficiency, and receipt status when mined

**Throws**

When the transaction is not found


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andrewkimjoseph.gitbook.io/celina-sdk/services/blockchainservice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
