@walletconnect/ethereum-provider 사용기

양태환·2023년 2월 15일
0

기(起)

월렛커넥트 v2.0 @walletconnect/ethereum-provider를 사용해보려한다

사용 실패이므로 사용 참고를 위해 오신 분들은 뒤로가주세요...ㅠ

승(承)

준비물은 npm 사이트 - https://www.npmjs.com/package/@walletconnect/ethereum-provider 와 ChatGPT이다.

프로젝트는 기본 react 프로젝트에 실행해봤다.
(나의 경우 이 파일의 위치는 reactDir/test_app)

전(轉)


화면에 버튼이 뜨긴 떴지만 아무 일도 일어나지 않는다...
코드는 이러하다.

import { EthereumProvider } from "@walletconnect/ethereum-provider";


export default function App() {
 
  async function tryConnect() {

    const provider = await EthereumProvider.init({
      projectId : "cdb3f2394c9b363fa73094e7eb02db42", // REQUIRED your projectId
      chains : 1, // REQUIRED chain ids
      // methods, // OPTIONAL ethereum methods
      events : "connect", // OPTIONAL ethereum events
      // rpcMap, // OPTIONAL rpc urls for each chain
      // metadata, // OPTIONAL metadata of your app
      // showQrModal, // OPTIONAL - `true` by default
    });

    // Web3Modal is enabled by default and will display a QR code modal
    await provider.enable();
  }
  
  return (
      <div>
        <div className="user">
        </div>
        <div className="connect">
          <button type="button" onClick={tryConnect}>
            active
          </button>
        </div>
      </div>
    );
}

결(結)

실패...
profile
당신의 오류 제가 잡아드립니다.

0개의 댓글

관련 채용 정보