# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
