---
# System prepended metadata

title: foundry cast 入門

---

# foundry cast 入門

Deploy `1_Storage.sol` with Remix

```solidity=
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.8.2 <0.9.0;

/**
 * @title Storage
 * @dev Store & retrieve value in a variable
 * @custom:dev-run-script ./scripts/deploy_with_ethers.ts
 */
contract Storage {

    uint256 number;

    /**
     * @dev Store value in variable
     * @param num value to store
     */
    function store(uint256 num) public {
        number = num;
    }

    /**
     * @dev Return value 
     * @return value of 'number'
     */
    function retrieve() public view returns (uint256){
        return number;
    }
}
```

Call on-chain data

```bash=
cast call \
--rpc-url $arbitrum_sepolia \
0x2C2e0791722d9c675FA8d23f9d45AF1ED22C8a24 \
"function retrieve() public view returns (uint256)"
```

Send a transaction

```bash=
cast send --account dev \
--rpc-url $arbitrum_sepolia \
0x2C2e0791722d9c675FA8d23f9d45AF1ED22C8a24 \
"function store(uint256 num)" \
24
```

Manage wallet with foundry cast

```bash=
cast wallet import dev --private-key <PRIVATE_KEY>
cast wallet list

# delete
rm -rf ~/.foundry/keystores/dev

```