> 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/tree/main/docs/api-reference/services/blockchain.service/README.md) / BlockchainService

## Class: BlockchainService

Defined in: [src/services/blockchain.service.ts:67](https://github.com/andrewkimjoseph/celina-sdk/blob/c35fe1db07a45a3cd14b2185df4abf2e6a2ec609/src/services/blockchain.service.ts#L67)

Celo mainnet block and transaction queries.

### Constructors

#### Constructor

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

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

**Parameters**

**clientFactory**

`CeloClientFactory`

**Returns**

`BlockchainService`

### Methods

#### checkAttributionInTransaction()

> **checkAttributionInTransaction**(`hash`, `tag?`): `Promise`<[`AttributionVerificationResult`](/celina-sdk/types/attributionverificationresult.md) & `object` & `object`>

Defined in: [src/services/blockchain.service.ts:238](https://github.com/andrewkimjoseph/celina-sdk/blob/c35fe1db07a45a3cd14b2185df4abf2e6a2ec609/src/services/blockchain.service.ts#L238)

Decode attribution from a mined transaction with a unified custom `tags` list.

**Parameters**

**hash**

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

Transaction hash

**tag?**

`string`

Optional tag to check (e.g. `celo_862c21dd97a7`)

**Returns**

`Promise`<[`AttributionVerificationResult`](/celina-sdk/types/attributionverificationresult.md) & `object` & `object`>

***

#### 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:97](https://github.com/andrewkimjoseph/celina-sdk/blob/c35fe1db07a45a3cd14b2185df4abf2e6a2ec609/src/services/blockchain.service.ts#L97)

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:157](https://github.com/andrewkimjoseph/celina-sdk/blob/c35fe1db07a45a3cd14b2185df4abf2e6a2ec609/src/services/blockchain.service.ts#L157)

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:74](https://github.com/andrewkimjoseph/celina-sdk/blob/c35fe1db07a45a3cd14b2185df4abf2e6a2ec609/src/services/blockchain.service.ts#L74)

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:193](https://github.com/andrewkimjoseph/celina-sdk/blob/c35fe1db07a45a3cd14b2185df4abf2e6a2ec609/src/services/blockchain.service.ts#L193)

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

***

#### verifyAttributionInTransaction()

> **verifyAttributionInTransaction**(`hash`, `tag?`): `Promise`<[`AttributionVerificationResult`](/celina-sdk/types/attributionverificationresult.md) & `object`>

Defined in: [src/services/blockchain.service.ts:215](https://github.com/andrewkimjoseph/celina-sdk/blob/c35fe1db07a45a3cd14b2185df4abf2e6a2ec609/src/services/blockchain.service.ts#L215)

Decode ERC-8021 attribution tags from a mined transaction's calldata.

**Parameters**

**hash**

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

Transaction hash

**tag?**

`string`

Optional tag to check (e.g. `celo_862c21dd97a7`)

**Returns**

`Promise`<[`AttributionVerificationResult`](/celina-sdk/types/attributionverificationresult.md) & `object`>


---

# 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
