> ## Documentation Index
> Fetch the complete documentation index at: https://daehan-base.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# wallet_connect

> 지갑을 연결하고 계정 접근 권한을 요청하는 Coinbase Wallet 전용 메서드입니다.

export const Button = ({children, disabled, variant = "primary", size = "medium", iconName, roundedFull = false, className = '', fullWidth = false, onClick = undefined}) => {
  const variantStyles = {
    primary: 'bg-blue text-black border border-blue hover:bg-blue-80 active:bg-[#06318E] dark:text-white',
    secondary: 'bg-white border border-white text-palette-foreground hover:bg-zinc-15 active:bg-zinc-30',
    outlined: 'bg-transparent text-white border border-white hover:bg-white hover:text-black active:bg-[#E3E7E9]'
  };
  const sizeStyles = {
    medium: 'text-md px-4 py-2 gap-3',
    large: 'text-lg px-6 py-4 gap-5'
  };
  const sizeIconRatio = {
    medium: '0.75rem',
    large: '1rem'
  };
  const classes = ['text-md px-4 py-2 whitespace-nowrap', 'flex items-center justify-center', 'disabled:opacity-40 disabled:pointer-events-none', 'transition-all', variantStyles[variant], sizeStyles[size], roundedFull ? 'rounded-full' : 'rounded-lg', fullWidth ? 'w-full' : 'w-auto', className];
  const buttonClasses = classes.filter(Boolean).join(' ');
  const iconSize = sizeIconRatio[size];
  return <button type="button" disabled={disabled} className={buttonClasses} onClick={onClick}>
      <span>{children}</span>
      {iconName && <Icon name={iconName} width={iconSize} height={iconSize} color="currentColor" />}
    </button>;
};

export const BaseBanner = ({content = null, id, dismissable = true}) => {
  const LOCAL_STORAGE_KEY_PREFIX = 'cb-docs-banner';
  const [isVisible, setIsVisible] = useState(false);
  const onDismiss = () => {
    localStorage.setItem(`${LOCAL_STORAGE_KEY_PREFIX}-${id}`, 'false');
    setIsVisible(false);
  };
  useEffect(() => {
    const storedValue = localStorage.getItem(`${LOCAL_STORAGE_KEY_PREFIX}-${id}`);
    setIsVisible(storedValue !== 'false');
  }, []);
  if (!isVisible) {
    return null;
  }
  return <div className="fixed bottom-0 left-0 right-0 bg-white py-8 px-4 lg:px-12 z-50 text-black dark:bg-black dark:text-white border-t dark:border-gray-95">
      <div className="flex items-center max-w-8xl mx-auto">
        {typeof content === 'function' ? content({
    onDismiss
  }) : content}
        {dismissable && <button onClick={onDismiss} className="flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors" aria-label="Dismiss banner">
          ✕
        </button>}
      </div>
    </div>;
};

지갑 연결을 수립하기 위한 Coinbase Wallet 전용 메서드입니다.

<Info>
  지갑이 dApp에 연결되고 계정 접근 권한을 제공하도록 요청합니다. 기본 동작은 `eth_requestAccounts`와 비슷하지만, 추가 연결 기능을 함께 요청할 수 있습니다.
</Info>

## 파라미터

<ParamField body="options" type="object">
  연결에 사용할 선택적 설정 객체입니다.

  <Expandable title="옵션 속성">
    <ParamField body="version" type="string">
      사용할 wallet connect 버전입니다.
    </ParamField>

    <ParamField body="jsonrpc" type="string">
      JSON-RPC 버전입니다. 보통 `"2.0"`을 사용합니다.
    </ParamField>

    <ParamField body="capabilities" type="object">
      연결 시 함께 요청할 선택적 capability 집합입니다. 예를 들어 인증을 위한 `signInWithEthereum`를 요청할 수 있습니다.

      <Expandable title="사용 가능한 capability">
        <ParamField body="signInWithEthereum" type="object">
          연결 과정에서 SIWE(Sign-In With Ethereum) 인증을 요청합니다.

          <Expandable title="signInWithEthereum 속성">
            <ParamField body="nonce" type="string" required>
              재전송 공격을 방지하기 위한 고유한 랜덤 문자열입니다.
            </ParamField>

            <ParamField body="chainId" type="string" required>
              16진수 문자열 형태의 체인 ID입니다. 예: Base Mainnet은 `"0x2105"`입니다.
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## 반환값

<ResponseField name="result" type="object">
  계정 정보와 capability 결과를 담은 연결 결과 객체입니다.

  <Expandable title="결과 속성">
    <ResponseField name="accounts" type="array">
      연결된 계정 객체 배열입니다.

      <Expandable title="계정 객체 속성">
        <ResponseField name="address" type="string">
          계정 주소입니다.
        </ResponseField>

        <ResponseField name="capabilities" type="object">
          연결 시 요청한 capability가 있다면 그 결과가 포함됩니다.

          <Expandable title="Capability 결과">
            <ResponseField name="signInWithEthereum" type="object">
              요청한 경우 SIWE 인증 결과가 반환됩니다.

              <Expandable title="signInWithEthereum 결과">
                <ResponseField name="message" type="string">
                  서명된 SIWE 형식 메시지입니다.
                </ResponseField>

                <ResponseField name="signature" type="string">
                  메시지의 암호학적 서명입니다.
                </ResponseField>
              </Expandable>
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="chainId" type="string">
      현재 체인 ID의 16진수 문자열입니다.
    </ResponseField>

    <ResponseField name="isConnected" type="boolean">
      지갑이 연결되었는지 여부입니다.
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```json Basic Connection theme={null}
  {
    "id": 1,
    "jsonrpc": "2.0",
    "method": "wallet_connect",
    "params": [{}]
  }
  ```

  ```json With Options theme={null}
  {
    "id": 1,
    "jsonrpc": "2.0",
    "method": "wallet_connect",
    "params": [{
      "version": "1.0",
      "jsonrpc": "2.0"
    }]
  }
  ```

  ```json With signInWithEthereum Capability theme={null}
  {
    "id": 1,
    "jsonrpc": "2.0",
    "method": "wallet_connect",
    "params": [{
      "version": "1",
      "capabilities": {
        "signInWithEthereum": {
          "nonce": "abc123def456",
          "chainId": "0x2105"
        }
      }
    }]
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Basic Connection Response theme={null}
  {
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
      "accounts": [{
        "address": "0x407d73d8a49eeb85d32cf465507dd71d507100c1"
      }],
      "chainId": "0x2105",
      "isConnected": true
    }
  }
  ```

  ```json signInWithEthereum Response theme={null}
  {
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
      "accounts": [{
        "address": "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
        "capabilities": {
          "signInWithEthereum": {
            "message": "localhost:3000 wants you to sign in with your Ethereum account:\n0x407d73d8a49eeb85d32cf465507dd71d507100c1\n\nSign in with Ethereum to the app.\n\nURI: http://localhost:3000\nVersion: 1\nChain ID: 8453\nNonce: abc123def456\nIssued At: 2024-01-15T10:30:00Z",
            "signature": "0x1234567890abcdef..."
          }
        }
      }],
      "chainId": "0x2105",
      "isConnected": true
    }
  }
  ```
</ResponseExample>

## 오류 처리

| Code   | Message                        | 설명                                                                |
| ------ | ------------------------------ | ----------------------------------------------------------------- |
| 4001   | User rejected the request      | 사용자가 연결 요청을 거부했습니다.                                               |
| 4100   | Requested method not supported | 지갑이 이 메서드를 지원하지 않습니다.                                             |
| 4200   | Wallet not available           | 지갑이 설치되어 있지 않거나 사용할 수 없습니다.                                       |
| -32602 | Invalid params                 | `signInWithEthereum` capability의 `nonce` 또는 `chainId`가 올바르지 않습니다. |

<Warning>
  이 메서드는 Coinbase Wallet 전용이며 다른 지갑에서는 제공되지 않을 수 있습니다.
</Warning>

<Info>
  연결이 성공하면 지갑은 연결 이벤트를 발생시키고 계정 정보에 접근할 수 있게 합니다.
</Info>

<Tip>
  `signInWithEthereum` capability를 사용할 때는 재전송 공격을 막기 위해 매 인증 시도마다 새로운 nonce를 생성하세요. 생성된 서명은 `viem` 같은 라이브러리로 백엔드에서 검증할 수 있습니다.
</Tip>

## Capability와 함께 사용하기

`wallet_connect`는 `signInWithEthereum` capability와 함께 사용해 사용자를 인증할 수 있습니다.

<BaseBanner
  id="privacy-policy"
  dismissable={false}
  content={({ onDismiss }) => (
<div className="flex items-center">
  <div className="mr-2">
    We're updating the Base Privacy Policy, effective July 25, 2025, to reflect an expansion of Base services. Please review the updated policy here:{" "}
    <a
      href="https://docs.base.org/privacy-policy-2025"
      target="_blank"
      className="whitespace-nowrap"
    >
      Base Privacy Policy
    </a>. By continuing to use Base services, you confirm that you have read and understand the updated policy.
  </div>
  <Button onClick={onDismiss}>I Acknowledge</Button>
</div>
)}
/>
