> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshoot with Arc Foundry

> Arc Foundry tools for replaying failed transactions, forking testnet state, and testing USDC interactions locally.

Arc Foundry extends standard Foundry with Arc-specific precompile logic.
Standard Foundry tools simulate a generic EVM and can't reproduce Arc-specific
failures like blocklisted address reverts or native USDC transfer errors. The
Arc Foundry tool you use depends on your debugging scenario.

## Replay failed transactions

`arc-cast run` replays a transaction at the block it was included in, showing
the exact revert reason, call trace, and state changes. Unlike standard
`cast run`, it includes Arc's precompile logic, so it can reproduce reverts from
blocklisted addresses, failed native USDC transfers, and other Arc-specific
conditions.

```bash theme={null}
arc-cast run <TX_HASH> \
  --rpc-url $ARC_TESTNET_RPC_URL
```

```text theme={null}
Traces:
  [34521] YourContract::yourFunction()
    ├─ [1200] <Arc precompile>::transfer(0xBlocklistedAddr, 1000000000000)
    │   └─ ← [Revert] "Blocklisted address"
    └─ ← [Revert]
```

## Fork testnet state

`arc-anvil --fork-url` starts a local node seeded with a snapshot of testnet
state. You can call contracts, send transactions, and impersonate accounts
without spending gas or waiting for block inclusion.

```bash theme={null}
arc-anvil --fork-url $ARC_TESTNET_RPC_URL
```

```text theme={null}
Forking from https://rpc.testnet.arc.io (block 2041837)
Listening on 127.0.0.1:8545
```

Once the fork is running, `arc-forge test` and `arc-cast` can target it. You can
also call contracts directly:

```bash theme={null}
arc-cast call <YOUR_CONTRACT_ADDRESS> "myFunction()(uint256)" \
  --rpc-url http://127.0.0.1:8545
```

<Tip>
  Fork a specific block to reproduce a historical issue: pass
  `--fork-block-number <BLOCK>` to `arc-anvil`. The local node serves the chain
  state exactly as it appeared at that block.
</Tip>

## Test USDC interactions

`arc-forge test --fork-url` runs your test suite against a live fork of Arc
testnet. A test that passes on standard `anvil` can still revert on Arc if your
contract treats `msg.value` and `USDC.balanceOf` as independent amounts. Both
views share one balance, but `msg.value` uses 18 decimals while `USDC.balanceOf`
uses 6 (see [EVM differences](/arc/references/evm-differences) for details).
Standard `anvil` doesn't simulate this.

```bash theme={null}
arc-forge test --fork-url $ARC_TESTNET_RPC_URL
```

```text theme={null}
Ran 2 tests for test/MyToken.t.sol:MyTokenTest
[PASS] testNativeTransfer() (gas: 51203)
[PASS] testUSDCBalance() (gas: 34821)

Suite result: ok. 2 passed; 0 failed
```

If any test fails, check whether your contract assumes separate native and
ERC-20 balances. On Arc, `msg.value` and `USDC.balanceOf` reflect the same
underlying balance at different decimal precisions. Adjust your assertions to
account for the 18-to-6 decimal conversion.

For more information about how Arc transactions behave differently from other
EVM blockchains, see [EVM differences](/arc/references/evm-differences).
