Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/guide/tempo-transaction/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Integrating Tempo Transactions is easy and can be done quickly by a developer in
| **Python** | [pytempo](https://github.com/tempoxyz/pytempo) | < 1 hour |
| **Other Languages** | Reach out to us! The specification is [here](/protocol/transactions/spec-tempo-transaction) and easy to build against. | 1-3 days |

If you are an EVM smart contract developer, see the [Tempo extension for Foundry](/sdk/foundry).
If you are an EVM smart contract developer, see the [Foundry guide for Tempo](/sdk/foundry).


## Properties
Expand Down
2 changes: 1 addition & 1 deletion src/pages/protocol/transactions/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Integrating Tempo Transactions is easy and can be done quickly by a developer in
| **Python** | [pytempo](https://github.com/tempoxyz/pytempo) | < 1 hour |
| **Other Languages** | Reach out to us! The specification is [here](/protocol/transactions/spec-tempo-transaction) and easy to build against. | 1-3 days |

If you are an EVM smart contract developer, see the [Tempo extension for Foundry](/sdk/foundry).
If you are an EVM smart contract developer, see the [Foundry guide for Tempo](/sdk/foundry).


## Properties
Expand Down
2 changes: 1 addition & 1 deletion src/pages/quickstart/verify-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ View the full API documentation at [contracts.tempo.xyz/docs](https://contracts.
## Troubleshooting

:::tip
If you encounter unexpected failures, you might be running an older version of Foundry/Forge, or you might not be running Tempo's Foundry fork. See the [Foundry setup guide](/sdk/foundry) for installation instructions.
If you encounter unexpected failures, you might be running an older version of Foundry/Forge. See the [Foundry setup guide](/sdk/foundry) for installation instructions.
:::

### Verification Failed
Expand Down
90 changes: 64 additions & 26 deletions src/pages/sdk/foundry/index.mdx
Original file line number Diff line number Diff line change
@@ -1,73 +1,112 @@
---
description: Build, test, and deploy smart contracts on Tempo using the Foundry fork. Access protocol-level features with forge and cast tools.
description: Build, test, and deploy smart contracts on Tempo using Foundry. Access Tempo protocol features with forge, cast, anvil, and chisel.
---

# Foundry for Tempo

Tempo builds on top of [Foundry](https://github.com/foundry-rs/foundry): the leading Ethereum development toolkit, through a custom fork that adds first-class support for Tempo.
Tempo is supported as a first-class citizen in [Foundry](https://github.com/foundry-rs/foundry): the leading Ethereum development toolkit.

This fork extends Foundry with Tempo's [protocol-level features](/protocol/), enabling developers to build, test, and deploy contracts that go [beyond the limits of standard EVM chains](/quickstart/evm-compatibility).
Install the latest nightly to access Tempo's [protocol-level features](/protocol/) in `forge`, `cast`, `anvil`, and `chisel`, and to build, test, and deploy contracts that go [beyond the limits of standard EVM chains](/quickstart/evm-compatibility).

:::warning[`tempo-foundry` is deprecated]
`tempo-foundry` and `foundryup -n tempo` are deprecated. Switch to upstream Foundry nightly with `foundryup --install nightly`.
:::

For general information about Foundry, see the [Foundry documentation](https://getfoundry.sh/).

## Get started with Foundry

Tempo's Foundry fork is installed through the standard upstream `foundryup` using the `-n tempo` flag, no separate installer is required.
Install the latest Foundry nightly to get Tempo support.

::::steps
:::::steps

## Install `foundryup`
### Install `foundryup`

If you don't have `foundryup` installed yet:

```bash
curl -L https://foundry.paradigm.xyz | bash
```

Or if you already have `foundryup` installed:
### Install the latest Foundry nightly

```bash
foundryup --update
foundryup --install nightly
```

## Install Tempo's Foundry fork
This installs the latest `nightly` release of [`forge`](https://getfoundry.sh/forge/overview#forge), [`cast`](https://getfoundry.sh/cast/overview#cast), [`anvil`](https://getfoundry.sh/anvil/overview#anvil), and [`chisel`](https://getfoundry.sh/chisel/overview#chisel).

```bash
foundryup -n tempo
```

This will automatically install the latest `nightly` release of all precompiled binaries: [`forge`](https://getfoundry.sh/forge/overview#forge), [`cast`](https://getfoundry.sh/cast/overview#cast), [`anvil`](https://getfoundry.sh/anvil/overview#anvil), and [`chisel`](https://getfoundry.sh/chisel/overview#chisel).

:::tip
To install a specific version, replace `<TAG_NAME>` with the desired release tag:

```bash
foundryup -n tempo -i <TAG_NAME>
foundryup --install <TAG_NAME>
```
:::

## Verify Installation
### Create a new Foundry project

Initialize a new Foundry project with the Tempo template:

```bash
forge -V
forge init -n tempo my-project && cd my-project
```

You should see version information include `-tempo`, indicating you are using the Tempo fork.
This gives you a Tempo-ready starter project, including the Tempo `Mail` example template.

If you're adding Tempo support to an existing Foundry project, install [`tempo-std`](https://github.com/tempoxyz/tempo-std) manually:

```bash
# forge <version>-tempo (<commit> <timestamp>)
forge install tempoxyz/tempo-std
```

## Create a new Foundry project
:::::

Initialize a new project with Tempo support:
## Configure `foundry.toml`

```bash
forge init -n tempo my-project && cd my-project
The Tempo template gives you a working starting point, but it is often useful to make Tempo explicit in `foundry.toml`.

### Configure RPC aliases

Set a default Tempo RPC alias and keep a separate alias for Moderato testnet:

```toml
[profile.default]
eth_rpc_url = "tempo"

[rpc_endpoints]
tempo = "${TEMPO_RPC_URL}"
moderato = "${TEMPO_TESTNET_RPC_URL}"
```

Each new project is configured for Tempo out of the box, with [`tempo-std`](https://github.com/tempoxyz/tempo-std), the Tempo standard library installed, containing helpers for Tempo's protocol-level features.
With this config, commands that use the default RPC pick up `tempo` automatically, and you can still switch explicitly with `--rpc-url moderato`.

### Activate Tempo features explicitly

::::
For most projects, the most flexible option is to enable Tempo network features directly:

```toml
[profile.default]
tempo = true
```

This network flag, enables Tempo-specific network behavior while still letting Foundry resolve the right semantics from the chain you are targeting.

If you need advanced testing against a specific Tempo hardfork, pin it explicitly in `foundry.toml` or via inline-config:

```toml
[profile.default]
hardfork = "tempo:T3"
```

This is the advanced option when you want local simulation, tests, or scripts to run against a specific Tempo hardfork such as T3. It also infers the Tempo network in Foundry's config layer.

### Verification config

Tempo's contract verifier is Sourcify-compatible. Configure verification with `VERIFIER_URL=https://contracts.tempo.xyz` or `--verifier-url https://contracts.tempo.xyz`.

The `[etherscan]` table in `foundry.toml` is for Etherscan-style verifiers, not Tempo's verifier.

## Use Foundry for your workflows

Expand Down Expand Up @@ -385,4 +424,3 @@ cast keychain key-info <ACCOUNT> <KEY_ID> \
cast keychain remaining-limit <ACCOUNT> <KEY_ID> <TOKEN_ADDRESS> \
--rpc-url $TEMPO_RPC_URL
```

32 changes: 15 additions & 17 deletions src/pages/sdk/foundry/mpp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { Card, Cards } from 'vocs'

# Use MPP with Foundry

[Tempo Foundry](https://github.com/tempoxyz/tempo-foundry) extends Foundry with native MPP support. When an RPC endpoint returns `402 Payment Required`, Foundry automatically handles the payment challenge — no wrapper scripts, no middleware, no code changes.
Foundry includes native MPP support on Tempo. When an RPC endpoint returns `402 Payment Required`, Foundry automatically handles the payment challenge with no wrapper scripts, middleware, or code changes.

:::warning[`tempo-foundry` is deprecated]
`tempo-foundry` and `foundryup -n tempo` are deprecated. Install upstream Foundry nightly with `foundryup -i nightly`.
:::

Every Foundry tool works transparently with MPP-gated endpoints:

Expand All @@ -26,32 +30,31 @@ When you point any Foundry tool at an MPP-gated RPC URL, the built-in transport
4. **Channel open** — If no payment channel exists, Foundry opens one on-chain with a deposit (default: `100,000` base units). This is a one-time on-chain lockup — unused balance remains in the channel.
5. **Voucher payment** — Foundry signs an off-chain voucher against the open channel and retries the request with an `Authorization: Payment` header.
6. **Auto top-up** — When a channel's deposit is exhausted, Foundry sends a top-up transaction. The server accepts it with `204 No Content`, then Foundry signs a fresh voucher and retries automatically.
6. **Channel reuse** — Subsequent requests reuse the same channel. Channel state is persisted to `$TEMPO_HOME/foundry/channels.json` (default `~/.tempo/foundry/channels.json`) across process invocations.
7. **Channel reuse** — Subsequent requests reuse the same channel. Channel state is persisted to `$TEMPO_HOME/foundry/channels.json` (default `~/.tempo/foundry/channels.json`) across process invocations.

:::tip
Channel reuse means the first call to an MPP endpoint has roughly one confirmation of overhead (~500ms on Tempo), but all subsequent calls add near-zero latency.
:::

## Setup
:::

:::note
Some endpoints use a one-shot `charge` intent instead of session-based channels. Foundry handles both — charge payments sign a single TIP-20 transfer without opening a channel.
:::
::::steps
:::::steps

### Install the Tempo CLI

```bash
curl -fsSL https://tempo.xyz/install | bash
```

### Install Tempo Foundry
### Install Foundry

Tempo's fork is installed through the standard `foundryup` using the `-n tempo` flag:
Tempo support now ships in Foundry's nightly:

```bash
foundryup -n tempo
foundryup -i nightly
```

All standard Foundry commands work as before — MPP activates only when an endpoint returns `402`.
Expand All @@ -78,7 +81,7 @@ Point any Foundry tool at an MPP-gated RPC URL. No additional flags or config ne
cast block-number --rpc-url https://rpc.mpp.tempo.xyz
```

::::
:::::

## Examples

Expand Down Expand Up @@ -206,15 +209,6 @@ Channels are automatically evicted when fully spent or closed. If the server res
Use the Moderato testnet MPP endpoint for development:

```bash
### Channel persistence

Open channels are saved to `$TEMPO_HOME/foundry/channels.json` (default `~/.tempo/foundry/channels.json`). This allows channel reuse across process invocations — you won't re-open a channel every time you run `cast` or `forge`.

Channels are automatically evicted when fully spent or closed. If the server restarts and returns `410 Gone`, Foundry clears stale local state and opens a fresh channel on the next request.

### Gas sponsorship

Some MPP endpoints sponsor gas fees on behalf of the caller. When the server's challenge includes a `feePayer` flag, Foundry delegates gas payment to the server — no TEMPO balance needed for gas.
cast block-number --rpc-url https://rpc.mpp.moderato.tempo.xyz

# Mainnet
Expand All @@ -223,6 +217,10 @@ cast block-number --rpc-url https://rpc.mpp.tempo.xyz

Fund your testnet wallet with `tempo wallet fund` before making requests.

### Gas sponsorship

Some MPP endpoints sponsor gas fees on behalf of the caller. When the server's challenge includes a `feePayer` flag, Foundry delegates gas payment to the server, so no native balance is needed for gas.

## Troubleshooting

| Error | Cause | Fix |
Expand Down
Loading