> For the complete documentation index, see [llms.txt](https://docs.eridian.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eridian.xyz/ethereum-dev/foundry-notes/useful-commands/cast.md).

# Cast

* `call` is used for viewing data
* `send` is used for modifying state (invoke functions, create contracts, etc.)

### Send ETH to an address

{% code overflow="wrap" %}

```bash
cast send <SENDER_ADDRESS> --value 1ether --rpc-url ${RPC_URL} --private-key ${PRIVATE_KEY}
```

{% endcode %}

### Call a view function

{% code overflow="wrap" %}

```bash
cast call <CONTRACT_ADDRESS> "getCreator()" --rpc-url ${RPC_URL}
```

{% endcode %}

### Invoke a function

```bash
cast send <CONTRACT_ADDRESS> "withdraw(address,uint256)" <ARG_1> <ARG_2> \
--rpc-url ${RPC_URL} --private-key ${PRIVATE_KEY}
```

### Get and send tokens on an anvil fork

```bash
cast rpc anvil_impersonateAccount <TOKEN_WHALE> --rpc-url ${RPC_URL}
cast send <TOKEN_ADDRESS> \
--from <TOKEN_WHALE> \
"transfer(address,uint256)(bool)" \
<RECEIVER_ACCOUNT> \
10000000 \
--unlocked \
--rpc-url ${RPC_URL}
```

### Hex Conversion

```bash
cast --to-base 0x6f dec
cast --to-hex 111
```

### Get storage slot from any contract

```bash
cast storage <CONTRACT_ADDRRESS> <STORAGE_SLOT> --rpc-url <RPC_URL>
```

### Get OPCODES for a contract

```bash
CONTRACT_NAME=

BYTECODE=$(jq -r '.bytecode.object' out/${CONTRACT_NAME}.sol/${CONTRACT_NAME}.json)
cast disassemble $BYTECODE > "${CONTRACT_NAME}-opcodes.txt"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.eridian.xyz/ethereum-dev/foundry-notes/useful-commands/cast.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
