---
title: How to Calculate Transaction Cost
description:
  "Every transaction costs compute units and a fee in lamports to execute on
  Solana. Learn how to calculate the cost of a transaction on Solana."
---

Every transaction consumes compute units and requires a transaction fee in
lamports to execute. The number of signatures included on a transaction
determines the base transaction fee (5000 lamports per signature).

<CodeTabs storage="cookbook" flags="r">

```typescript !! title="Kit" file=packages/docs-examples/cookbook/transactions/calculate-cost/kit.ts#region=cost

```

```ts !! title="Web3.js v3" file=packages/docs-examples/cookbook/transactions/calculate-cost/web3v3.ts#region=cost

```

```rust !! title="Rust" file=packages/docs-examples/cookbook/transactions/calculate-cost/rust/src/main.rs#region=cost

```

```py !! title="Python" file=packages/docs-examples/cookbook/transactions/calculate-cost/python.py#region=cost

```

```go !! title="Go" file=packages/docs-examples/cookbook/transactions/calculate-cost/go/main.go#region=cost

```

```ts !! title="Web3.js (legacy)" file=packages/docs-examples/cookbook/transactions/calculate-cost/legacy.ts#region=cost

```

</CodeTabs>
