Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deployment details for hardhat and foundry #107

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 67 additions & 4 deletions docs/deploying/deploy-smart-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ You will need to enter your password to decrypt the private key and view the acc

## 3. Deploy your smart contract(s)

By default `yarn deploy` will deploy contract to the local network. You can change `defaultNetwork` in:

```mdx-code-block
<Tabs groupId="dev-tool">
<TabItem value="hardhat" label="Hardhat" default>
```

By default `yarn deploy` will deploy all the contracts from your `packages/hardhat/contracts` folder to the local network. You can change `defaultNetwork` in:

```sh
packages/hardhat/hardhat.config.ts
```
Expand All @@ -131,20 +131,81 @@ packages/hardhat/hardhat.config.ts
<TabItem value="foundry" label="Foundry">
```

By default `yarn deploy` will deploy all the contracts from your `packages/foundry/contracts` folder to the local network. You can change `defaultNetwork` in:

```sh
packages/foundry/foundry.toml
```

</TabItem>
</Tabs>

Run the command below to deploy the smart contract to the target network. Make sure to have your encryption password and some funds in your deployer account to pay for the transaction.
### 3.1 Deploy specific contracts

To deploy specific contracts instead of all of them, you can follow these steps:

```mdx-code-block
<Tabs groupId="dev-tool">
<TabItem value="hardhat" label="Hardhat" default>
```

1. Add tags to the deploy scripts located in `packages/hardhat/deploy`. For example `01_deploy_my_contract.ts`:

```ts
deployMyContract.tags = ["tagExample"];
```

2. Run `yarn deploy --tags tagExample` to run all the scripts with the "tagExample" tag.

`````mdx-code-block
</TabItem>
<TabItem value="foundry" label="Foundry">

1. Each contract that you wish to deploy individually should have its own deployment script in `packages/foundry/script`. For example: `DeployMyContract.s.sol`

2. Run the specific deployment script using:

```sh
yarn deploy --file DeployMyContract.s.sol
```
If you don't specify the `--file` parameter, the deployment will use the default `Deploy.s.sol` file. This default file can be configured to deploy multiple contracts in a specific order when you run the `yarn deploy` command.

</TabItem>
</Tabs>

### 3.2 Deploy to specific networks

Run the command below to deploy the smart contracts to the target network. Make sure to have your encryption password and some funds in your deployer account to pay for the transaction.

```
yarn deploy --network network_name
```

eg: `yarn deploy --network sepolia`
```mdx-code-block
<Tabs groupId="dev-tool">
<TabItem value="hardhat" label="Hardhat" default>
```

You can also specify a tag:

```sh
yarn deploy --network sepolia --tags tagExample
```

````mdx-code-block
</TabItem>
<TabItem value="foundry" label="Foundry">

Requires custom keystore setup, see [generate accounts](#2-generate-a-new-account-or-add-one-to-deploy-the-contracts-from)

You can also specify a file:

```sh
yarn deploy --network sepolia --file DeployMyContract.s.sol
```

</TabItem>
</Tabs>

## 4. Verify your smart contract

Expand Down Expand Up @@ -209,3 +270,5 @@ For production-grade applications, it's recommended to obtain your own API keys
:::tip Hint
It's recommended to store envs for nextjs in Vercel/system env config for live apps and use .env.local for local testing.
:::tip Hint
```
`````
Loading