# Deployment guide

### Settings

First install all dependencies and set all the environment variables needed in a .env file

### Deployment and upgrades management

For this project it was used the hardhat-deploy plugin to manage everything related to deployments, upgrades, tasks, interaction scripts and verify process, this plugin has support for EIP 2535 Diamond standard, and this allow some built in features that helps with the development process.

### Commands

To deploy run the next command

```
yarn hardhat deploy --network <network_to_deploy> --tags takaturn_deploy
```

To upgrade run the next one

```
yarn hardhat deploy --network <network_to_deploy> --tags takaturn_upgrade
```

That will run the correct script

### Managing upgrades

When the first deploy is made, a folder with the corresponding network info is created inside the deployment folder. It is important to not delete this folder, as long as we can find here the json file for the Diamond proxy, upgrades will be made correctly. If the file is deleted, a new Diamond will be deployed every time.

### Verification

The deploy scripts are set to verify the Diamond proxy and each Facet implementation, but it can be the case when the verification fails due to various reasons (errors on the arbiscan API, lack of block verification after deployment, etc. if this happens it can be solved by two different ways. You can either run again the deploy command (this will reuse the same address and try verification again) or run the next command

```
yarn hardhat sourcify --network <network_deployed> --contract-name <contract_to_verify>
```
