> 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/contractservice.md).

# ContractService

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

***

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

## Class: ContractService

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

Read-only and gas-estimation helpers for arbitrary contracts.

### Constructors

#### Constructor

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

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

**Parameters**

**clientFactory**

`CeloClientFactory`

**Returns**

`ContractService`

### Methods

#### callFunction()

> **callFunction**(`params`): `Promise`<{ `contractAddress`: `` `0x${string}` ``; `error?`: `undefined`; `functionName`: `string`; `network`: `"mainnet"`; `result`: `unknown`; `success`: `boolean`; } | { `contractAddress`: `` `0x${string}` ``; `error`: `string`; `functionName`: `string`; `network`: `"mainnet"`; `result`: `null`; `success`: `boolean`; }>

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

Simulate a read-only contract call (`eth_call`).

**Parameters**

**params**

[`ContractCallParams`](/celina-sdk/types/contractcallparams.md)

Contract address, ABI, function name, and optional args

**Returns**

`Promise`<{ `contractAddress`: `` `0x${string}` ``; `error?`: `undefined`; `functionName`: `string`; `network`: `"mainnet"`; `result`: `unknown`; `success`: `boolean`; } | { `contractAddress`: `` `0x${string}` ``; `error`: `string`; `functionName`: `string`; `network`: `"mainnet"`; `result`: `null`; `success`: `boolean`; }>

Decoded result on success; `{ success: false, error }` on revert

***

#### estimateGas()

> **estimateGas**(`params`): `Promise`<{ `contractAddress`: `` `0x${string}` ``; `error?`: `undefined`; `functionName`: `string`; `gasEstimate`: `string`; `gasPrice`: `string`; `network`: `"mainnet"`; `success`: `boolean`; `totalCost`: `string`; } | { `contractAddress`: `` `0x${string}` ``; `error`: `string`; `functionName`: `string`; `gasEstimate`: `string`; `gasPrice`: `string`; `network`: `"mainnet"`; `success`: `boolean`; `totalCost`: `string`; }>

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

Estimate gas for a contract call from `fromAddress`.

**Parameters**

**params**

[`ContractCallParams`](/celina-sdk/types/contractcallparams.md) & `object`

Same as `callFunction` plus required `fromAddress`

**Returns**

`Promise`<{ `contractAddress`: `` `0x${string}` ``; `error?`: `undefined`; `functionName`: `string`; `gasEstimate`: `string`; `gasPrice`: `string`; `network`: `"mainnet"`; `success`: `boolean`; `totalCost`: `string`; } | { `contractAddress`: `` `0x${string}` ``; `error`: `string`; `functionName`: `string`; `gasEstimate`: `string`; `gasPrice`: `string`; `network`: `"mainnet"`; `success`: `boolean`; `totalCost`: `string`; }>

Gas estimate, current gas price, and total cost in wei


---

# 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/contractservice.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.
