# getUploadCosts

> **getUploadCosts**(`client`, `options`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/warm-storage/namespaces/getuploadcosts/type-aliases/outputtype/)\>

Defined in: [packages/synapse-core/src/warm-storage/get-upload-costs.ts:128](https://github.com/FilOzone/synapse-sdk/blob/840d7b2c6263846ac51b7558000e62dd68d33a44/packages/synapse-core/src/warm-storage/get-upload-costs.ts#L128)

Read-only function that computes upload costs, reserve-aware deposit needed,
and approval state.

Fetches account state, pricing, and approval via read-only contract calls,
then delegates all cost arithmetic to the shared pure
`calculateUploadCosts` utility. To price an upload to an existing data set,
pass `dataSetId` and its state is read on-chain. Callers that already hold
that state can instead pass `isNewDataSet: false` with `dataSetLeafCount`,
`currentLifecycleReserveBalance`, and `pdpEndEpoch`, plus
`pendingOneTimePayments` when the data set has unflushed lifecycle fees.
Multi-piece fee and reserve estimates conservatively treat each piece as a
separate add-pieces operation because actual batching is runtime-dependent.

Approval is checked with `isFwssMaxApproved`: only an unlimited FWSS
approval counts. A bounded approval reports `needsFwssMaxApproval: true`
and `ready: false`, even when its remaining allowances cover this upload.

The result includes the payer `account` values used in the calculation, so
callers can show the balance after depositing without reading the account
again.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `client` | `Client`\<`Transport`, `Chain`\> | The client to use to compute upload costs. |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/warm-storage/namespaces/getuploadcosts/type-aliases/optionstype/) | [getUploadCosts.OptionsType](/reference/filoz/synapse-core/warm-storage/namespaces/getuploadcosts/type-aliases/optionstype/) |

## Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/warm-storage/namespaces/getuploadcosts/type-aliases/outputtype/)\>

[getUploadCosts.OutputType](/reference/filoz/synapse-core/warm-storage/namespaces/getuploadcosts/type-aliases/outputtype/)

## Throws

When existing-data-set state or piece sizes are invalid, the data set does not exist, or the data-set service is terminated [getUploadCosts.ErrorType](/reference/filoz/synapse-core/warm-storage/namespaces/getuploadcosts/type-aliases/errortype/)

## Example

```ts
import { getUploadCosts } from '@filoz/synapse-core/warm-storage'
import { calibration } from '@filoz/synapse-core/chains'
import { createPublicClient, http } from 'viem'

const client = createPublicClient({
  chain: calibration,
  transport: http(),
})

const costs = await getUploadCosts(client, {
  clientAddress: '0x1234567890123456789012345678901234567890',
  dataSetId: 1n,
  pieceSizes: [1_000_000n],
})

const { availableFunds, debt } = costs.account
console.log(costs.depositNeeded, availableFunds + costs.depositNeeded - debt)
```