# Migration guide

Do you have a Hardhat project and you want to deploy it to [AI Trader](https://ais-organization-2.gitbook.io/ai-trader/ai-trader)? In this page you'll find all the steps you need to do to migrate an existing Hardhat project to AI Trader.

### Overview <a href="#overview" id="overview"></a>

AITrader offers multiple Hardhat plugins with different features but in this guide we'll focus on only the ones you'd need to do to migrate your project to AI Trader.

### Install dependencies <a href="#install-dependencies" id="install-dependencies"></a>

Although AI Trader is compatible with Solidity and Vyper, the deployed bytecode and the deployment process is different from Ethereum or other [AVM](https://ais-organization-2.gitbook.io/ai-trader/docs/avm) blockchains. So the fist step will be to install the compiler and deployer hardhat plugins.

#### Full configuration <a href="#full-configuration" id="full-configuration"></a>

```
import { HardhatUserConfig } from "hardhat/config";

import "@matterlabs/hardhat-aitrader-deploy";
import "@matterlabs/hardhat-aitrader-solc";

const config: HardhatUserConfig = {
  aisolc: {
    version: "1.3.1",
    compilerSource: "binary",
    settings: {},
  },
  defaultNetwork: "aitrader Testnet",
  networks: {
    hardhat: {
      aitrader: false,
    },
    goerli:{
      url: 'https://goerli.com/api/abcdef12345',
      aitrader: false,
    }
    mainnet:{
      url: 'https://ethereum.mainnet.com/api/abcdef12345',
      aitrader: false,
    },
    aitrader Testnet: {
      url: "https://aitrader2-testnet.aitrader.dev",
      ethNetwork: "goerli",  // or a Goerli RPC endpoint from Infura/Alchemy/Chainstack etc.
      aitrader: true,
    },
  },
  solidity: {
    version: "0.8.17",
  },
  // OTHER SETTINGS...
};

export default config;

```

### Deploy contracts <a href="#deploy-contracts" id="deploy-contracts"></a>

To deploy your contracts you'd need to use the `Deployer` class from the `hardhat-`aitrader`-deploy` plugin. This class takes care of all the specifics of deploying contracts on aitrader.

Here is a basic deployment script for a `Greeter` contract:

```
import { utils, Wallet } from "aitrader-web3";
import * as ethers from "ethers";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Deployer } from "@matterlabs/hardhat-aitrader-deploy";

// An example of a deploy script that will deploy and call a simple contract.
export default async function (hre: HardhatRuntimeEnvironment) {
  console.log(`Running deploy script`);

  // Initialize the wallet.
  const wallet = new Wallet("<WALLET-PRIVATE-KEY>");

  // Create deployer object and load the artifact of the contract we want to deploy.
  const deployer = new Deployer(hre, wallet);
  // Load contract
  const artifact = await deployer.loadArtifact("Greeter");

  // Deploy this contract. The returned object will be of a `Contract` type, 
  // similar to the ones in `ethers`.
  const greeting = "Hi there!";
  // `greeting` is an argument for contract constructor.
  const greeterContract = await deployer.deploy(artifact, [greeting]);

  // Show the contract info.
  console.log(`${artifact.contractName} was deployed to ${greeterContract.address}`);
}
```

\
Include your deployment script in the `deploy` folder and execute it runnin

```
# Yarn
yarn hardhat deploy-aitrader --script SCRIPT_FILENAME.ts --network aitraderTestnet

# NPM
npx hardhat deploy-aitrader --script SCRIPT_FILENAME.ts --network aitraderTestnet
```
