# calculateUploadCosts

> **calculateUploadCosts**(`options`): [`OutputType`](/reference/filoz/synapse-core/utils/namespaces/calculateuploadcosts/type-aliases/outputtype/)

Defined in: [packages/synapse-core/src/utils/calculate-upload-costs.ts:179](https://github.com/FilOzone/synapse-sdk/blob/0c729dad461472f017e4d84f8e6ac16e6afbe7c0/packages/synapse-core/src/utils/calculate-upload-costs.ts#L179)

Calculate upload costs from already-resolved pricing, account, and data-set state.

Context-specific rates, fees, and lockups are calculated independently and
summed. Account debt, available funds, runway, and the execution buffer are
then applied exactly once to the aggregate, making this function suitable
for both single-copy and multi-copy uploads.

This function performs no network requests and does not mutate its inputs.
Callers must resolve existing data-set and payer state at a consistent chain
snapshot before calling it.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/utils/namespaces/calculateuploadcosts/type-aliases/optionstype/) | [calculateUploadCosts.OptionsType](/reference/filoz/synapse-core/utils/namespaces/calculateuploadcosts/type-aliases/optionstype/) |

## Returns

[`OutputType`](/reference/filoz/synapse-core/utils/namespaces/calculateuploadcosts/type-aliases/outputtype/)

Aggregated upload costs and funding readiness [calculateUploadCosts.OutputType](/reference/filoz/synapse-core/utils/namespaces/calculateuploadcosts/type-aliases/outputtype/)

## Throws

ValidationError when no contexts are supplied or context state is invalid

## Example

```ts
import { calculateUploadCosts } from '@filoz/synapse-core/utils'
import { getPriceList } 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 priceList = await getPriceList(client)

const costs = calculateUploadCosts({
  contexts: [{ pieceSizes: [1_000_000n], withCDN: false, dataSet: null }],
  priceList,
  account: {
    currentLockupRate: 0n,
    debt: 0n,
    availableFunds: 0n,
    runwayInEpochs: 0n,
    fwssMaxApproved: true,
  },
})

console.log(costs.depositNeeded)
```