# 2. Astar EVM IDE 使用流程演示

{% embed url="<https://www.youtube.com/watch?v=5m3-Ff17mjo>" %}

## 1. 编写合约

进入项目后，文件夹中自带的 readme.md 文件会自动预览。&#x20;

<figure><img src="/files/5lGaOMNF7z2fHG3Od7rt" alt=""><figcaption></figcaption></figure>

在 Explorer 栏中，你可以新建文件（夹），刷新目录，下载文件。也可以直接点击模板中自带的文件。

<figure><img src="/files/8t9xIXug9VzNIv14t2RT" alt=""><figcaption></figcaption></figure>

点击一个合约文件，即可对代码进行编辑操作。

<figure><img src="/files/jtgaA9CbSrA83YRpmob2" alt=""><figcaption></figcaption></figure>

## 2. 编译合约

合约代码编写完成后，点击右侧菜单栏的 Compiler 按钮打开编译模块，选择 Compiler 版本和是否开启 Optimization，然后点击 Compile \*\*\*.sol 启动编译。

<figure><img src="/files/ej8rTmnJ27wd2ADduXt6" alt=""><figcaption></figcaption></figure>

编译成功后，下方会显示 [ABI](https://docs.soliditylang.org/en/latest/abi-spec.html) 和 BYTE CODE ，同时控制台上会输出 Compile contract success 的信息提示。

<figure><img src="/files/6JB7fXrTd8H9MhfjZvm7" alt="" width="326"><figcaption></figcaption></figure>

## 3. 连接 Astar EVM

部署合约前，需要先点击右上角的 Connect Wallet，选择连接到 JavaScript VM (使用 JavaScript 实现的 EVM，主要用于测试) 或 Metamask （可部署到 Astar 区块链上）。

<figure><img src="/files/3KyntyIq6J8URR2uWgN5" alt=""><figcaption></figcaption></figure>

## 4. 部署合约

点击右侧的 Deploy\&Interaction 按钮，出现部署页与交互页面。选择好已编译的合约后，点击 Deploy进行部署（然后在 Metamask 中点击确认）。合约部署成功后，控制台上会输出现合约部署的结果以及相关信息。&#x20;

<figure><img src="/files/jvil3UGVx1gMcwO1ygUm" alt=""><figcaption></figcaption></figure>

除此之外，你还可以点击 Import Deployed Contract 导入已部署过的合约，来进行合约交互。

<figure><img src="/files/qgtV0vHqxgO4iYyT9Vog" alt=""><figcaption></figcaption></figure>

## 5. 合约交互

合约部署成功后，可以对合约进行交互操作。点击已部署好的合约，选择对应的接口，点击 Submit 或 Get   进行交互。

<figure><img src="/files/5ROKybWigSinlmwnI51c" alt=""><figcaption></figcaption></figure>

## 6. 交易查询

点击 Output 中的交易 Hash，可以查看每笔交易的具体信息。

<figure><img src="/files/xbka8frQwZrHVfuQ6Mnl" alt=""><figcaption></figcaption></figure>

## 7. 验证合约

点击右侧  Scan Verifier 插件，选择需要验证的合约，填入已部署的合约地址，点击 Verify。

<figure><img src="/files/vtBUwvT4fr5Oj8UTGtHj" alt=""><figcaption></figcaption></figure>

验证成功后，可查看到在 blockscout scan 上已验证的合约链接。

<figure><img src="/files/ln2zJtDc6xubkDfUtL8x" alt=""><figcaption></figcaption></figure>

## 8. Astar EVM Sandbox&#x20;

如果你喜欢使用命令行进行开发，可以打开 Astar EVM Sandbox，其中已自带 [Hardhat](https://hardhat.org/), [Truffle](https://trufflesuite.com/), [Brownie](https://eth-brownie.readthedocs.io/en/stable/) [Ganache](https://trufflesuite.com/ganache/), [Git](https://git-scm.com/) and [Node.js V16](https://nodejs.org/en)。

<figure><img src="/files/unI1ROEyA1wPUl0Liua8" alt=""><figcaption></figcaption></figure>

ChainIDE 为全栈开发提供了支持。例如，如果您使用 Voting dApp 或 Hardhat dApp Wave 模板，您不仅可以编译和部署您的智能合约，还可以通过 ChainIDE 的端口转发功能为您的 dApp 前端提供服务。请参考 [ChainIDE-端口转发](/chainide-chinese/5.-port-forwarding.md)。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chainide.gitbook.io/chainide-chinese/chainide/12.-astar-ide/2.-astar-evm-ide-shi-yong-liu-cheng-yan-shi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
