> For the complete documentation index, see [llms.txt](https://whs3-doge5k.gitbook.io/smartcontract-security-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whs3-doge5k.gitbook.io/smartcontract-security-docs/basics/5.-metamask/metamask-ethernaut.md).

# Metamask와 Ethernaut 상호작용

Ethernaut 문제 풀이를 위해 전 강의에서 만든 지갑을 Ethernaut와 연동한다.

## 1. Metamask와 Ethernaut 연동하기

{% embed url="<https://ethernaut.openzeppelin.com/>" %}

선행 강의를 완벽히 이행하고 Ethernaut에 접속하면 **Metamask account not connected** 팝업이 뜬다.

<figure><img src="https://2462457462-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLf9vwRuaws92ULgGvzTi%2Fuploads%2F8Z0xYoJzsRXhVQUlIaj0%2Fimage.png?alt=media&amp;token=b9019e2a-02a9-4959-a8f1-b470cce0b816" alt="" width="375"><figcaption></figcaption></figure>

<mark style="color:red;">`connect`</mark>를 누르고  MetaMask를 통해 서명하면 자동으로 연결된다.

## 2.  Instance 요청하기

각 문제의 맨 아래에 <mark style="color:red;">`Get New Instance`</mark>가 존재한다.

오른쪽의 팝업에서 confirm하고 조금 기다리면 트랜잭션이 confirm 되었다는 팝업이 뜬다.

<figure><img src="https://2462457462-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLf9vwRuaws92ULgGvzTi%2Fuploads%2FxsJbSg4eobsHA3jyCbCo%2Fimage.png?alt=media&amp;token=bbbf2c11-e723-448b-a889-f05f22eb616a" alt="" width="375"><figcaption></figcaption></figure>

chrome 개발자 도구에서 해당 Instance와와 상호작용 할 수 있다(<mark style="color:red;">`f12`</mark>  or  <mark style="color:red;">`ctrl + shift + i`</mark>).

## 3. Ethernaut와 Metamask의 상호작용

#### 1. Get new instance

* ethernaut가 이더리움 Testnet에  트랜잭션 요청
* MetaMask가 사용자에게 서명 요청
* transaction 실행: 해당 사용자만을 위한 별도의 instance를 블록체인에 배포
* ethernaut는 브라우저 콘솔에 instance를 저장

#### 2. Exploit

#### 3. Submit Instance

Ethernaut의 백엔드에서 사용자의 MetaMask 주소와 해당 Instance의 주소를 가지고 블록체인 상에서 검증 함수를 호출, 상태를 확인한다.
