# Deploying Contract

Deploying and compiling the contract is different for the Polygon CDK, here we discuss the steps to deploy your first contract in the Polygon CDK network.

**Step 1: Get the RPC URL -** follow the instructions on the [RPC Access ](/rollups/polygon-cdk-zkrollup/demo-network/rpc-access.md)page to get the RPC endpoints.

**Step 2:** **Get ABI and bytecode -** Deploying a contract in polygon CDK is the same as deploying a contract in the Ethereum network. You can compile the contract code in bytecode and abi normally as you would do for Ethereum and then can use it in the next step.

**Step 3: Replace Values -** Replace **RPC\_URL, contractAbi, contractBytecode** and **privateKey.** once you replace those values with valid values, you can run the file with **ts-node filename.ts**

```typescript
import { ethers } from "ethers";

async function deployContract() {
    // Replace with your Ethereum node's RPC endpoint
    const RPC_URL = "https://demouser:demopass@rpcnode.demo-vali-02aa6b.zeeve.net/rpc";
    // Connect to your Ethereum node
    const provider = new ethers.JsonRpcProvider(RPC_URL);

    // Replace these values with your contract's ABI and bytecode
    const contractAbi = []; // Your contract's ABI as an array
    const contractBytecode = ""; // Your contract's bytecode as a hex string

    // Set the account that will deploy the contract
    const privateKey = ""; // Replace with the private key of the account deploying the contract
    const wallet = new ethers.Wallet(privateKey, provider);
    console.log(`wallet address: ${wallet.address} bal: ${await provider.getBalance(wallet.address)}`);

    // Create a contract factory
    const MyContractFactory = new ethers.ContractFactory(contractAbi, contractBytecode, wallet);
    console.log("contract ready to deploy");

    // Deploy the contract
    const MyContract = await MyContractFactory.deploy(10);

    // Wait for the contract to be mined
    await MyContract.waitForDeployment();
    console.log("contract deployed");

    console.log(`Contract deployed successfully at address: ${await MyContract.getAddress()}`);
}

deployContract();
```

**Step 4: Contract Address -** Once it runs successfully you will get a contract address.

<figure><img src="/files/xcaYoLdjmp1vWkeLFfq1" alt=""><figcaption><p>Success Message</p></figcaption></figure>


---

# 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.zeeve.io/rollups/polygon-cdk-zkrollup/demo-network/deploying-contract.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.
