- [Interacting with the contract](#interacting-with-the-contract)
This document focuses on the minimal setup required to deploy a smart contract to the Ethereum blockchain. It assumes you have already set up your development environment and have a test Ethereum wallet.
_mint(msg.sender, initialSupply * 10 ** decimals()); // Mints tokens to the contract creator
}
}
```
### Configuring Hardhat
Then, if using Typescript, edit the config file `hardhat.config.ts` to include the following:
```typescript
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import dotenv from "dotenv";
dotenv.config();
const config: HardhatUserConfig = {
solidity: "0.8.20",
networks: {
sepolia: {
url: process.env.ALCHEMY_SEPOLIA_RPC,
accounts: [process.env.PRIVATE_KEY as string],
},
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY, // Optional, for contract verification
},
};
export default config;
```
To explain each environment variable:
-`ALCHEMY_SEPOLIA_RPC`: The RPC URL for the Sepolia test network. You can get this from [Alchemy](https://www.alchemy.com/chain-connect/endpoints/rpc-sepolia-sepolia).
-`PRIVATE_KEY`: The private key of your test wallet. You can get this from MetaMask by clicking on the three dots next to your wallet and selecting "Account details".
-`ETHERSCAN_API_KEY`: Your Etherscan API key. You can get this by creating an account on [Etherscan](https://etherscan.io/).
Create a `.env` file in the root directory and add the following:
```plaintext
ALCHEMY_SEPOLIA_RPC=<your_rpc_url>
PRIVATE_KEY=<your_private_key>
ETHERSCAN_API_KEY=<your_etherscan_api_key>
```
### Deployment
We need to create a deploy script in the `scripts` directory. Create a new file called `deploy.ts` and paste the following code:
You can send it via the MetaMask extension by clicking "Send" and pasting the contract address. You have to import the contract first by clicking "Import" and pasting the contract address.