> For the complete documentation index, see [llms.txt](https://scroll-zkp.gitbook.io/scroll-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scroll-zkp.gitbook.io/scroll-guide/developers/contract-deployment-tutorial.md).

# Contract Deployment Tutorial

{% hint style="danger" %}
**Scroll Alpha Testnet is now deprecated.**

Please visit our new documentation for the Scroll Sepolia Testnet at <https://docs.scroll.io/>
{% endhint %}

Our Alpha Testnet allows the community to deploy smart contracts on Scroll. In this tutorial, we will teach you how to deploy a contract on the Scroll Testnet. This [demo repo](https://github.com/scroll-tech/scroll-guides/tree/main/contract-deploy-demo) illustrates contract deployment with [Hardhat](https://hardhat.org/) and [Foundry](https://github.com/foundry-rs/foundry).

{% hint style="info" %}
Note: Before you start deploying the contract, you need to request test tokens from a [Goerli faucet](/scroll-guide/user-guide/faucet.md) and use the [bridge](https://scroll.io/alpha/bridge) to transfer some test`ETH`from *Goerli* to *Scroll Alpha*.
{% endhint %}

### Deploy contracts with Hardhat

1. If you haven't already, install [nodejs](https://nodejs.org/en/download/) and [yarn](https://classic.yarnpkg.com/lang/en/docs/install).
2. Clone the repo and install dependencies

```shell
git clone https://github.com/scroll-tech/scroll-guides.git
cd scroll-guides/contract-deploy-demo
yarn install
```

3\. Create a `.env` file following the example `.env.example` in the root directory. Change `PRIVATE_KEY` to your own account private key in the `.env`.

4\. Run `yarn compile` to compile the contract.

5\. Run `yarn deploy:scrollTestnet` to deploy the contract on the Scroll Alpha Testnet.

6\. Run `yarn test` for hardhat tests.

### Deploy contracts with Foundry

1. Clone the repo.

```shell
git clone https://github.com/scroll-tech/scroll-guides.git
cd scroll-guides/contract-deploy-demo
```

2\. Install Foundry.

```shell
curl -L https://foundry.paradigm.xyz | bash
foundryup
```

3\. Run `forge build` to build the project.

4\. Deploy your contract with Foundry

```bash
forge create --rpc-url https://alpha-rpc.scroll.io/l2 \
  --value <lock_amount> \
  --constructor-args <unlock_time> \
  --private-key <your_private_key> \
  --legacy \
  contracts/Lock.sol:Lock
```

* `<lock_amount>` is the amount of test `ETH` to be locked in the contract. Try setting this to some small amount, like `0.0000001ether`.&#x20;
* `<unlock_time>` is the Unix timestamp after which the funds locked in the contract will become available for withdrawal. Try setting this to some Unix timestamp in the future, like `1696118400` (this Unix timestamp corresponds to October 1, 2023).

For example:

```bash
forge create --rpc-url https://alpha-rpc.scroll.io/l2 \
  --value 0.00000000002ether \
  --constructor-args 1696118400 \
  --private-key 0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1 \
  --legacy contracts/Lock.sol:Lock
```

### Questions and Feedback

Thank you for participating in and developing on the Scroll Alpha Testnet. If you encounter any issues, join our [Discord](https://discord.gg/scroll) and ask us in the `developers` channels.

#### Developer Notes

1. The `SELFDESTRUCT` opcode is disabled and will not be supported in Scroll, as it is slated to be removed from the EVM at a later date.
2. For now, we have set Layer 2 gas prices to be the same as on Ethereum Layer 1. However, these gas prices are subject to change and will be set in the future to match proving costs. We will endeavor to minimize these changes, primarily applying them to ZK-unfriendly precompiles when necessary for security.
3. For now, we recommend using `london` as a target EVM version for compiling. You can read more on that in the [Ethereum & Alpha Testnet differences ](/scroll-guide/developers/ethereum-and-alpha-testnet-differences.md#evm-target-version)section.
4. `CREATE` and `CREATE2` opcodes will yield the **same behaviour** as on Ethereum mainnet. Computation and address calculation is done in the same manner as on Ethereum.


---

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

```
GET https://scroll-zkp.gitbook.io/scroll-guide/developers/contract-deployment-tutorial.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.
