> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy on Arc

> Deploy and interact with a Solidity smart contract on Arc Testnet using Arc Foundry.

export const TryOnArcStudio = () => {
  const [copied, setCopied] = useState(false);
  const [prompt, setPrompt] = useState("");
  useEffect(() => {
    const url = `https://docs.arc.io${window.location.pathname}.md`;
    setPrompt(`Read the guide at ${url}, implement it in a new project, then run it and show me how it works.`);
  }, []);
  const arcStudioUrl = `https://studio.arc.io/app?prompt=${encodeURIComponent(prompt)}`;
  const handleArcStudioClick = () => {
    try {
      if (typeof navigator !== "undefined" && navigator.clipboard && prompt) {
        navigator.clipboard.writeText(prompt).then(() => {
          setCopied(true);
          setTimeout(() => setCopied(false), 4000);
        }, () => {});
      }
    } catch (e) {}
  };
  return <div className="not-prose mb-6">
      <span className="relative inline-flex">
        <a href={arcStudioUrl} target="_blank" rel="noreferrer" onClick={handleArcStudioClick} aria-label="Try it on Arc Studio (opens in new tab)" className="inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[#3E74BB] border border-[#3E74BB] text-sm font-medium text-white no-underline hover:bg-[#345f9c] hover:border-[#345f9c] transition-all">
          <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
            <path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z" />
          </svg>
          Try it on Arc Studio
        </a>
        {copied && <span role="status" aria-live="polite" className="absolute left-0 top-full mt-2 w-72 text-sm text-gray-500 dark:text-[#888]">
            Opening Arc Studio — prompt copied to your clipboard in case you need to
            sign in first.
          </span>}
      </span>
    </div>;
};

<TryOnArcStudio />

Deploy a contract to Arc Testnet and interact with it onchain. You'll initialize
a starter project and use the generated `Counter` contract to complete the full
deploy pipeline before developing your own contracts.

## Prerequisites

Before you begin, ensure that you've:

* [Installed Arc Foundry](/arc/tutorials/install-arc-foundry)
* Installed [Git](https://git-scm.com/)

## Step 1. Initialize a project

From your working directory, initialize a new project:

```shell theme={null}
arc-forge init hello-arc && cd hello-arc
```

This generates `src/Counter.sol`, a matching test file at `test/Counter.t.sol`,
and a deployment script at `script/Counter.s.sol`. The generated `.gitignore`
already excludes `.env` from version control.

## Step 2. Configure the RPC connection

Create a `.env` file in the project root with the Arc Testnet RPC URL:

```ini theme={null}
ARC_TESTNET_RPC_URL="https://rpc.testnet.arc.io"
```

Load the variables into your shell:

```shell theme={null}
source .env
```

<Tip>
  Never commit your `.env` file to version control. Store private keys and
  sensitive variables securely.
</Tip>

## Step 3. Test the contract

From your `hello-arc` project directory, run the `Counter` tests against Arc's
runtime before deploying:

```shell theme={null}
arc-forge test --network arc
```

The `--network arc` flag catches Arc-specific issues that a generic EVM
simulator would miss. Use it when testing your own contracts, too.

<Tip>
  Use `arc-anvil --network arc` to run a local Arc node during development. It
  supports forking testnet state and testing contract interactions manually
  before deploying.
</Tip>

## Step 4. Set up your wallet

### 4.1. Create a wallet

Create a new wallet with `arc-cast`. If you already have a development wallet,
skip this and add your wallet's private key to your `.env` file in step 4.2
instead:

```shell theme={null}
arc-cast wallet new
```

The command returns an address and private key:

```text theme={null}
Successfully created new keypair.
Address:     0xB815A0c4bC23930119324d4359dB65e27A846A2d
Private key: 0xcc1b30a6af68ea9a9917f1dd••••••••••••••••••••••••••••••••••••••97c5
```

<Warning>
  Keep your private key secure. Never share it or commit it to source control.
  Use environment variables or a secrets manager for any non-test deployment.
</Warning>

### 4.2. Configure your `.env`

Add the private key to your `.env` file and reload:

```ini theme={null}
PRIVATE_KEY="0x..."
```

```shell theme={null}
source .env
```

### 4.3. Fund your wallet

Visit the [Circle Faucet](https://faucet.circle.com), select **Arc Testnet**,
enter your wallet address, and request testnet USDC.
[Arc uses USDC for gas](/arc/references/gas-and-fees), so this balance covers
your deployment fees.

<Info>
  Testnet USDC is for testing purposes only. You can't use it in production.
</Info>

## Step 5. Deploy to Arc Testnet

### 5.1. Deploy the contract

Deploy to Arc Testnet:

```shell theme={null}
arc-forge create src/Counter.sol:Counter \
  --rpc-url $ARC_TESTNET_RPC_URL \
  --private-key $PRIVATE_KEY \
  --broadcast
```

Replace `src/Counter.sol:Counter` with your own contract path and name when
deploying your own contracts.

After deployment completes, you'll see output similar to:

```text theme={null}
Deployer: 0xB815A0c4bC23930119324d4359dB65e27A846A2d
Deployed to: 0x32368037b14819C9e5Dbe96b3d67C59b8c65c4BF
Transaction hash: 0xeba0fcb5e528d586db0aeb2465a8fad0299330a9773ca62818a1827560a67346
```

Save the `Deployed to` address from the output to your `.env` file and reload:

```ini theme={null}
COUNTER_ADDRESS="0x..."
```

```shell theme={null}
source .env
```

### 5.2. Verify the contract on Arc Testnet Explorer

Arc Testnet Explorer runs Blockscout, so you can publish your contract's source
code with `arc-forge verify-contract` and Foundry's Blockscout verifier.
Verified contracts show a **Contract** tab on the explorer with source code,
ABI, and a read/write UI.

Run the verification command from your Foundry project root, using the same
compiler settings you used to deploy:

```shell theme={null}
arc-forge verify-contract $COUNTER_ADDRESS src/Counter.sol:Counter \
  --chain-id 5042002 \
  --verifier blockscout \
  --verifier-url https://explorer.testnet.arc.io/api/
```

If your contract's constructor takes arguments, ABI-encode them with
`arc-cast abi-encode` and pass the result with `--constructor-args`. For
example:

```shell theme={null}
arc-forge verify-contract $CONTRACT_ADDRESS src/MyToken.sol:MyToken \
  --chain-id 5042002 \
  --verifier blockscout \
  --verifier-url https://explorer.testnet.arc.io/api/ \
  --constructor-args $(arc-cast abi-encode "constructor(string,string)" "MyToken" "MTK")
```

<Tip>
  You can also submit source code manually from the [contract verification
  page](https://explorer.testnet.arc.io/contract-verification) on the explorer
  if you didn't deploy with Foundry.
</Tip>

After verification succeeds, open the deployed address on
[explorer.testnet.arc.io](https://explorer.testnet.arc.io) to confirm the
**Contract** tab now shows the verified source and lets you call functions
directly from the UI.

## Step 6. Interact with your contract

Confirm the deployment on the
[Arc Testnet Explorer](https://explorer.testnet.arc.io) by entering the
transaction hash from step 5.1.

Read the current counter value with `arc-cast call`:

```shell theme={null}
arc-cast call $COUNTER_ADDRESS "number()(uint256)" \
  --rpc-url $ARC_TESTNET_RPC_URL
```

A freshly deployed `Counter` returns `0`. Increment it onchain with
`arc-cast send`:

```shell theme={null}
arc-cast send $COUNTER_ADDRESS "increment()" \
  --rpc-url $ARC_TESTNET_RPC_URL \
  --private-key $PRIVATE_KEY
```

Re-run the `arc-cast call` command. The returned value is now `1`.

You now have a working deployment pipeline on Arc Testnet. To deploy
production-ready tokens or NFTs without writing Solidity, see
[Deploy contracts](/arc/tutorials/deploy-contracts).

<Note>
  If you encounter unexpected behavior after deploying, see [Troubleshoot with
  Arc Foundry](/arc/tutorials/troubleshoot-with-arc-foundry).
</Note>
