# Switch chains

You read and change the wallet's active network through the [Ethereum provider](/docs/products/embedded-wallet/swift/wallet/ethereum-provider), using the standard `eth_chainId` and [`wallet_switchEthereumChain`](https://docs.metamask.io/wallet/reference/wallet_switchethereumchain/) JSON-RPC calls. Chain ids are passed as **hex strings** (e.g. Base Sepolia `84532` is `"0x14a34"`).

## Read the current chain

`eth_chainId` takes no params and returns the chain id as a hex string. Convert to decimal if you need it:

```swift
guard let provider = try await OFSDK.shared.getEthereumProvider(params: OFGetEthereumProviderParams()) else {
    print("Provider not available")
    return
}

let chainIdHex = try await provider.request(method: "eth_chainId", params: [])
let chainIdDec = chainIdHex.flatMap { Int($0.dropFirst(2), radix: 16) }
print("chainId hex: \(chainIdHex ?? "?"), dec: \(chainIdDec.map(String.init) ?? "?")")
```

## Switch to another chain

Send `wallet_switchEthereumChain` with the target `chainId` as a hex string:

```swift
guard let provider = try await OFSDK.shared.getEthereumProvider(params: OFGetEthereumProviderParams()) else {
    print("Provider not available")
    return
}

// Switch to Base Sepolia (84532 == 0x14a34)
_ = try await provider.request(
    method: "wallet_switchEthereumChain",
    params: [["chainId": "0x14a34"]]
)
print("Switched chain")
```

:::warning
**EOA wallets default to Base mainnet (`8453`).** If you configured an `.eoa` and want to transact on another network, call `wallet_switchEthereumChain` **before** sending — otherwise the transaction goes out on Base mainnet. Smart accounts use the `chainId` they were configured with.
:::

:::note
Smart accounts only operate on [supported chains](/docs/configuration/chains). Switching to an unsupported chain will fail. EOAs are chain-agnostic and work anywhere.
:::

## Next steps

* [Send a transaction](/docs/products/embedded-wallet/swift/wallet/send)
* [Sponsored (gasless) transactions](/docs/products/embedded-wallet/swift/wallet/eip-7702)
