지갑이 dApp에 연결되고 계정 접근 권한을 제공하도록 요청합니다. 기본 동작은
eth_requestAccounts와 비슷하지만, 추가 연결 기능을 함께 요청할 수 있습니다.파라미터
object
연결에 사용할 선택적 설정 객체입니다.
Show 옵션 속성
Show 옵션 속성
string
사용할 wallet connect 버전입니다.
string
JSON-RPC 버전입니다. 보통
"2.0"을 사용합니다.반환값
object
계정 정보와 capability 결과를 담은 연결 결과 객체입니다.
{
"id": 1,
"jsonrpc": "2.0",
"method": "wallet_connect",
"params": [{}]
}
{
"id": 1,
"jsonrpc": "2.0",
"method": "wallet_connect",
"params": [{
"version": "1.0",
"jsonrpc": "2.0"
}]
}
{
"id": 1,
"jsonrpc": "2.0",
"method": "wallet_connect",
"params": [{
"version": "1",
"capabilities": {
"signInWithEthereum": {
"nonce": "abc123def456",
"chainId": "0x2105"
}
}
}]
}
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"accounts": [{
"address": "0x407d73d8a49eeb85d32cf465507dd71d507100c1"
}],
"chainId": "0x2105",
"isConnected": true
}
}
{
"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
}
}
오류 처리
| Code | Message | 설명 |
|---|---|---|
| 4001 | User rejected the request | 사용자가 연결 요청을 거부했습니다. |
| 4100 | Requested method not supported | 지갑이 이 메서드를 지원하지 않습니다. |
| 4200 | Wallet not available | 지갑이 설치되어 있지 않거나 사용할 수 없습니다. |
| -32602 | Invalid params | signInWithEthereum capability의 nonce 또는 chainId가 올바르지 않습니다. |
이 메서드는 Coinbase Wallet 전용이며 다른 지갑에서는 제공되지 않을 수 있습니다.
연결이 성공하면 지갑은 연결 이벤트를 발생시키고 계정 정보에 접근할 수 있게 합니다.
signInWithEthereum capability를 사용할 때는 재전송 공격을 막기 위해 매 인증 시도마다 새로운 nonce를 생성하세요. 생성된 서명은 viem 같은 라이브러리로 백엔드에서 검증할 수 있습니다.Capability와 함께 사용하기
wallet_connect는 signInWithEthereum capability와 함께 사용해 사용자를 인증할 수 있습니다.