---
eip: 2255
label: EIP-2255
title: Wallet Permissions System
status: Final
type: Standards Track
category: Interface
created: 2019-08-22
requires: 1193
official: https://eips.ethereum.org/EIPS/eip-2255
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2255.md
canonical: https://eips.huatuo.xyz/ko/eip-2255/
lang: ko
tldr: "지갑 프로바이더 API에 wallet_requestPermissions와 wallet_getPermissions를 추가해, dapp이 모든 동작마다 프롬프트를 띄우는 대신 이름 붙은 권한(예: 계정 보기)을 한 번만 요청하게 한다."
tags: [wallet, permissions, rpc, provider, interface]
---

# EIP-2255: Wallet Permissions System

> An interface to restrict access to sensitive methods

**TL;DR:** 지갑 프로바이더 API에 wallet_requestPermissions와 wallet_getPermissions를 추가해, dapp이 모든 동작마다 프롬프트를 띄우는 대신 이름 붙은 권한(예: 계정 보기)을 한 번만 요청하게 한다.

## 어떤 문제를 해결하나요?

지갑은 신뢰할 수 없는 웹사이트와 사용자의 키 사이에 있습니다. 안전한 기본값은 모든 것을 물어보는 것이지만, 그러면 온보딩이 팝업의 연속이 됩니다. 주소 공개, 네트워크 전환, 챌린지 서명, 토큰 승인, 트랜잭션 전송 같은 것들입니다.

웹 사용자는 OAuth("~로 로그인")에서 더 나은 패턴을 알고 있습니다. 사이트가 원하는 것을 나열한 화면 하나에서 사용자가 승인하거나 거부하거나 범위를 좁힐 수 있습니다. EIP-2255는 작고 범용적인 권한 API로 이 모델을 지갑에 가져옵니다.

## 어떻게 동작하나요?

[EIP-1193](/eip-1193/) 프로바이더에 두 가지 메서드가 있습니다.

**`wallet_requestPermissions`**는 메서드 이름을 caveat 객체에 매핑한 객체 하나를 받습니다.

```ts
interface PermissionRequest {
  [methodName: string]: { [caveatName: string]: any };
}
```

지갑이 프롬프트를 보여 줍니다. 사용자가 승인하면 `{ parentCapability, date? }` 배열을 반환합니다. 사용자가 거부하면 코드 `4001`(EIP-1193의 user rejected) 오류를 던집니다.

**`wallet_getPermissions`**는 매개변수가 없으며 현재 사이트가 가진 권한을 반환합니다(기본값은 비어 있음).

```ts
interface Permission {
  invoker: string;           // origin of the dapp, e.g. "https://app.example"
  parentCapability: string;  // the permitted method, e.g. "eth_accounts"
  caveats: { type: string; value: any }[]; // restrictions on that permission
}
```

제한된 메서드를 호출하면 해당 권한이 부여될 때까지 실패합니다. **Caveat**으로 권한을 좁힐 수 있습니다. 예를 들어 사이트가 특정 서명 방식을 지원하는 계정만 요청하거나, 사용자가 만료 기한을 추가할 수 있습니다.

## 샘플 코드

계정 접근 권한을 명시적으로 요청하고 무엇이 부여되었는지 확인하는 예(브라우저, EIP-1193 프로바이더):

```ts
const provider = (window as any).ethereum;

try {
  await provider.request({
    method: "wallet_requestPermissions",
    params: [{ eth_accounts: {} }],
  });
} catch (err: any) {
  if (err.code === 4001) console.log("User rejected the request");
  else throw err;
}

const permissions = await provider.request({ method: "wallet_getPermissions" });
const hasAccounts = permissions.some((p: any) => p.parentCapability === "eth_accounts");

if (hasAccounts) {
  const accounts = await provider.request({ method: "eth_accounts" });
  console.log(accounts);
}
```

## 알아둘 점

- 상태는 **Final**입니다. MetaMask는 두 메서드를 모두 지원하며, 다른 지갑은 제각각이므로 기능 감지를 하고 `eth_requestAccounts`로 폴백하세요.
- 이 EIP가 정의하는 것은 요청과 응답의 형태이지, 어떤 권한이나 caveat이 존재하는지가 아닙니다. 그것은 지갑마다 다릅니다.
- 지갑이 사이트의 아이콘을 보여 줄 때는 임의의 URL을 가져오는 데 주의해야 합니다(명세는 서버 측 요청 위조에 대해 경고합니다).
- [ERC-7715](/eip-7715/)(Draft)는 이 아이디어를 바탕으로 세션 키 같은 더 풍부하고 범위가 한정된 권한을 제공합니다. 관련된 지갑 RPC로는 체인 추가와 전환을 다루는 [EIP-3085](/eip-3085/)와 [EIP-3326](/eip-3326/)이 있습니다.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-2255
