> For the complete documentation index, see [llms.txt](https://blockchain-sports.gitbook.io/atleta-network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blockchain-sports.gitbook.io/atleta-network/devs/build-testent/deploy-your-evm-app/hardhat.md).

# Hardhat

#### What is Hardhat?[​](https://docs.manta.network/docs/zkShuffle/Deploy/Hardhat#what-is-hardhat) <a href="#what-is-hardhat" id="what-is-hardhat"></a>

Hardhat is a development environment for Ethereum that helps developers manage and automate the common tasks involved in building smart contracts and decentralized applications. It can directly interact withAtleta Olympia's Ethereum API, allowing for the deployment of smart contracts into the Atleta Olympia network. Additionally, Hardhat is a comprehensive set of tools for creating Ethereum-based software, which includes various components that aid in editing, compiling, debugging, and deploying smart contracts and decentralized applications. All of these components work together to create a complete development environment.

#### Creating a Hardhat Project[​](https://docs.manta.network/docs/zkShuffle/Deploy/Hardhat#creating-a-hardhat-project) <a href="#creating-a-hardhat-project" id="creating-a-hardhat-project"></a>

1. Create a directory for your project

```shell
mkdir hardhat && cd hardhat
```

2. Initialize the project which will create a package.json file

```sh
npm init -y
```

3.Install Hardhat

```sh
npm install hardhat
```

4.Create a project

```shell
npx hardhat
```

5.Create an empty hardhat.config.js and install the Ethers plugin to use the Ethers.js library to interact with the network.

```sh
npm install @nomiclabs/hardhat-ethers ethers
```

#### Creating your Smart Contract[​](https://docs.manta.network/docs/zkShuffle/Deploy/Hardhat#creating-your-smart-contract) <a href="#creating-your-smart-contract" id="creating-your-smart-contract"></a>

1. Create a contracts directory

```sh
mkdir contracts && cd contracts
```

2. Create your\_contract.sol file in contracts directory

```sh
touch your_contract.sol
```

#### Creating your Configuration File[​](https://docs.manta.network/docs/zkShuffle/Deploy/Hardhat#creating-your-configuration-file) <a href="#creating-your-configuration-file" id="creating-your-configuration-file"></a>

Modify the Hardhat configuration file and create a secure file to store your private key in.

1. Create a secrets.json file to store your private key

```sh
touch secrets.json
```

2. Add your private key to secrets.json

```json
{
    "privateKey": "YOUR-PRIVATE-KEY-HERE"
}
```

1. Add the file to your project's .gitignore, and never reveal your private key.
2. Modify the hardhat.config.js file

* Import the Ethers plugin
* Import the secrets.json file
* Inside the module.exports add the Atleta Olympia network configuration

```javascript
//hardhat.config.js

require('@nomiclabs/hardhat-ethers');
const { privateKey } = require('./secrets.json');

module.exports = {
  solidity: "0.8.1",
  defaultNetwork: "rinkeby",
  networks: {
    rinkeby: {
      url: "https://eth-rinkeby.alchemyapi.io/v2/123abc123abc123abc123abc123abcde",
      accounts: [privateKey]
    },
    atletaOlympia: {
      url: "https://testnet-rpc.atleta.network",  // Insert your RPC URL Here
      chainId: 2340, //Insert your ChainID Here
    }
  },
}
```

#### Deploying your Smart Contract[​](https://docs.manta.network/docs/zkShuffle/Deploy/Hardhat#deploying-your-smart-contract) <a href="#deploying-your-smart-contract" id="deploying-your-smart-contract"></a>

1. Compile the contract

```sh
npx hardhat compilejs
```

2. Create a new directory for the script and name it scripts and add a new file to it called deploy.js

```sh
mkdir scripts && cd scripts
touch deploy.js
```

3. Create a deployment script, like the one below

```javascript
// scripts/deploy.js
async function main() {
   // 1. Get the contract to deploy
   const Your_Contract = await ethers.getContractFactory('your_contract');
   console.log('Deploying Your_Contract...');

   // 2. Instantiating a new smart contract
   const your_contract = await Your_Contract.deploy();

   // 3. Waiting for the deployment to resolve
   await your_contract.deployed();

   // 4. Use the contract instance to get the contract address
   console.log('Your_Contract deployed to:', your_contract.address);
}

main()
   .then(() => process.exit(0))
   .catch((error) => {
      console.error(error);
      process.exit(1);
   });
```

4. Deploy your\_contract.sol using the command below

```sh
npx hardhat run scripts/deploy.js --network atletaOlympia
```
