# Check the ETH price and swap USDC on Base
Source: https://docs.chain.link/solutions/chainlink-for-agents/guides/check-price-and-swap

> For the complete documentation index, see [llms.txt](/llms.txt).

> **NOTE: Prerequisites**
>
> 1. This guide assumes that you have already linked your agent to the Chainlink platform, and have created a fresh wallet for it, using [our guide here](/solutions/chainlink-for-agents/guides/set-guardrails). You also need:
>    - A few USDC on Base left in your agent's address, to pay this guide's fees.
>    - About 6 USDC on Base in the new chain wallet.
>    - Your agent doesn't need any ETH: it pays its fees in USDC, and Chainlink covers the gas for its chain wallet.
> 2. This guide assumed you have set up appropriate guardrails relevant to your needs, as described in [our guide here](/solutions/chainlink-for-agents/guides/set-guardrails).

In this tutorial, you will:

1. Have your agent fetch live token prices from Chainlink's Data Streams.
2. Swap USDC for ETH on Base through Uniswap.
3. Check your agent's balances after the swap.
4. Watch a guardrail block a swap.

> **TIP: Agent address vs. chain wallet**
>
> Your agent works with two addresses:
>
> - **Agent address:** the address your agent created during sign-up, and the one you linked to your organization. It's your agent's identity, and your agent pays its Chainlink for Agents fees from it.
> - **Chain wallet:** a [smart contract wallet](/crec/concepts/smart-accounts) that Chainlink deploys for your agent on each chain it uses, such as Base. It holds the tokens your agent swaps or sends. It has no private key of its own: it only carries out instructions signed with your agent's key and delivered by Chainlink.
>   - We might also refer to it as an SVA (Signature Verifying Account).
>
> Your agent's swaps run from its chain wallet, so Chainlink for Agents can check each one against your guardrails before it goes onchain. Your link covers both addresses, but guardrails only apply to what your agent does from its chain wallet.

## Check the ETH price

This serves as the first test of your agent's connection to the Chainlink platform.

Give this prompt to your agent:

```
What's the current price of ETH in US dollars? Get it from Chainlink Data Streams through Chainlink for Agents.
```

The agent should be able to fetch the latest price straight from the platform via Chainlink Data Streams.
Simply reading the data doesn't require us to set up a separate chain wallet, but the next step does.

![Screenshot showing the agent fetching the current ETH price from Chainlink Data Streams.](/images/solutions/chainlink-for-agents/check-price-and-swap/check-price-and-swap-2.png)

## Swap USDC for ETH using Uniswap

Remember the guardrails we set up earlier? We allowed our wallet to be able to swap tokens on Uniswap. Let us see if that works.

Give this prompt to your agent to initiate the swap:

```
Swap 5 USDC for ETH on Base from your chain wallet.

Before you sign, show me what I'll get and wait for my confirmation.
```

> You can also edit the prompt to have your agent simply execute the swap without asking for confirmation.

![Screenshot showing the agent preparing to swap USDC for ETH on Uniswap.](/images/solutions/chainlink-for-agents/check-price-and-swap/check-price-and-swap-4.png)

- Before moving forward, ask your agent to check if the swap went through, and make sure your balances reflect the updated amounts.

## Watch a guardrail block a swap

1. Go to the [Chainlink platform's agent dashboard](https://app.chain.link/cre/agents), and locate your agent.
2. Click on the `Settings` icon and configure your existing settings to turn off `Uniswap` token swaps. Click on `Apply Settings`.
3. Paste this prompt to try and swap your remaining `USDC` for `ETH` **after turning** off Uniswap swaps from inside the UI.

```
Swap 1 USDC for ETH on Base please.
```

Your agent should now refuse to execute the swap, as the guardrail for Uniswap swaps has been turned off.

![Screenshot showing the agent refusing to swap USDC for ETH after Uniswap swaps are turned off.](/images/solutions/chainlink-for-agents/check-price-and-swap/check-price-and-swap-5.png)

## What's next

You've seen your guardrails allow one swap and block the next. From here, try changing one setting at a time and asking your agent for something new. Keep the amounts small while you experiment.

Some ideas:

- **Earn yield on Aave**: Turn on the `Aave - deposits and withdrawals` setting, then ask your agent to interact with the protocol.
- **Bridge using CCIP**: Turn on the setting and try sending a cross-chain swap. Maybe configure an allowlist and try sending tokens to a wallet that is **NOT** on the allowlist?

To see everything else your agent can do, go back to [What can your agent do](/solutions/chainlink-for-agents#what-can-your-agent-do).

## Disclaimer

Please note, this repo contains community examples only — these are not Chainlink products or services and are not supported or maintained by Chainlink. This code represents an example of using a Chainlink product or service, and is intended for demonstration and educational purposes only. It is provided “AS IS” and “AS AVAILABLE” without warranties of any kind, may not have been audited, and may omit checks or error handling. Each party intending to use this example code does so entirely at their own risk and must perform its own audits, security and code review, key management, and testing before any production deployment and ensure the operation and performance of such code matches expectations. Neither Chainlink Labs nor the Chainlink Foundation deploys, operates, monitors, maintains or endorses any deployment of this code. Note that this is not a Chainlink product, feature or service, and there are no commitments made with respect to the code, including compatibility with future Chainlink releases. You should not rely on this code without first conducting your own technical, engineering, and security review. This code is also outside the scope of any Chainlink bug bounty programs. Neither Chainlink Labs, the Chainlink Foundation, nor Chainlink node operators are responsible for outcomes due to errors in this example or how it is deployed or operated, or liable for any resulting claims or damages. Use of the Chainlink Network is subject to the Chainlink Foundation [Terms of Service](https://chain.link/terms), which provides important information and disclosures. By using this code, you acknowledge and agree to these terms.