# How to deploy and verify new contracts on DBK Chain

In this tutorial, we'll walk through deploying a smart contract on DBK Chain

## Prerequisites

* Bridge to DBK Chain here: [Bridging to DBK Chain](https://docs.dbkchain.io/bridge/bridge-sdk)
* Have [foundry](https://github.com/foundry-rs/foundry) installed on your PC
* Have a basic understanding of Solidity and Blockchain

## Write Your First Contract

The most popular smart contract development language today is Solidity. In this tutorial, you'll be using Foundry to write, compile, and deploy a simple smart contract to DBK Chain.Foundry is a smart contract development toolchain. Foundry manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the command-line and via Solidity scripts.

### Creating a New Project

To start a new project with Foundry, use forge init:

```bash
$ forge init hello_world
```

For now, let’s check what the default template looks like:

```bash
$ cd hello_foundry
$ tree . -d -L 1
.
├── lib
├── script
├── src
└── test

5 directories
```

The default template comes with one dependency installed: Forge Standard Library. This is the preferred testing library used for Foundry projects. Additionally, the template also comes with an empty starter contract and a simple test.

Let’s build the project:

```bash
$ forge build
[⠊] Compiling...
[⠊] Compiling 27 files with Solc 0.8.25
[⠒] Solc 0.8.25 finished in 956.80ms
Compiler run successful!

```

### Create an empty contract file

Let's create a new contract file in the src directory. You can do this by running the following command in your terminal:

```bash
touch src/MyFirstContract.sol
```

### Write your first contract

This tutorial will show you how to deploy a simple contract that has a storage variable you can read and write. You'll be able to update this variable with a transaction and then retrieve the updated value. This is just a simple example to get you started.

Copy and paste the following code into the file you just created.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
 
contract HelloWorld {
    string public message;
 
    function setMessage(string memory _message) public {
        message = _message;
    }
}
```

### Compile your contract

To compile your contract, run the following command in your terminal:

```bash
$ forge build
[⠊] Compiling...
[⠢] Compiling 1 files with Solc 0.8.25
[⠆] Solc 0.8.25 finished in 106.64ms
```

### Deploy your contract

Forge can deploy smart contracts to a given network with the forge create command. Forge CLI can deploy only one contract at a time.

To deploy MyContract to a network:

```bash
$ forge create --rpc-url https://rpc.mainnet.dbkchain.io/ --private-key <your_private_key> src/MyFirstContract.sol:HelloWorld
[⠊] Compiling...
No files changed, compilation skipped
Deployer: 0x5853eD4f26A3fceA565b3FBC698bb19cdF6DEB85
Deployed to: 0x7eF4f140E0cD7b3187a7c91ece0a631F306BE5F5
Transaction hash: 0x3432673ae4838b71e3f3fee6a5a286fdd76822ca7e063cada8bb5e6cf8459192
```

### Verify your contract

You can verify your contract on the DBK Chain explorer by running the following command in your terminal:

```bash
$ forge verify-contract 0x7eF4f140E0cD7b3187a7c91ece0a631F306BE5F5 src/MyFirstContract.sol:HelloWorld --verifier blockscout --verifier-url https://scan.dbkchain.io/api\?

Submitting verification for [src/MyFirstContract.sol:HelloWorld] 0x7eF4f140E0cD7b3187a7c91ece0a631F306BE5F5.
Submitted contract for verification:
        Response: `OK`
        GUID: `7ef4f140e0cd7b3187a7c91ece0a631f306be5f5667e1af6`
        URL: https://etherscan.io/address/0x7ef4f140e0cd7b3187a7c91ece0a631f306be5f5
```

![alt text](https://2662127220-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4J4tnls2sAagC1StHBDF%2Fuploads%2Fgit-blob-df5e6dbb842c943f41ff05b359940ef5dc1eeabb%2Ffa907d37-3b8f-483e-8981-229eb5efa3cc.jpeg?alt=media)
