Biport 월렛 가이드
  • Overview
  • ⛳온보딩 프로세스
    • 바이포트 지갑 설치하기
    • 새 지갑 만들기
    • 기존 지갑 가져오기
  • 💡바이포트 사용 튜토리얼
    • 친구에게 자산 전송하기
    • 홈 화면에 토큰 추가하기
    • 스마트컨트랙트 전송 방지하기
    • 메타마스크 지원 기능 이용하기
    • BiFi에 예금하기
  • 🖨️API Documentation
    • 시작하기
      • Biport 감지하기
      • 사용자의 네트워크 감지하기
      • 사용자의 계정 접근하기
    • API
      • Biport provider API
      • JSON-RPC API
  • ❓서포트
    • Audit
    • 고객센터
    • English
    • 모바일 가이드
Powered by GitBook
On this page
  • Methods
  • 지원하지 않는 Methods

Was this helpful?

  1. API Documentation
  2. API

JSON-RPC API

PreviousBiport provider APINextAudit

Last updated 2 years ago

Was this helpful?

Biport는 window.biport.request(args) provider method를 사용하여 JSON-RPC API를 래핑합니다.

표준 Ethereum RPC 메소드에 대한 자세한 내용은 를 참조하십시오.

모든 RPC 메소드 요청은 오류를 반환할 수 있습니다. window.biport.request(args)를 호출할 때마다 오류 처리를 반드시 해야 합니다.

아래는 RPC 메소드 중 eth_chainId 로 호출하는 예제입니다.

window.biport.request({ method: 'eth_chainId' })
    .then((chainId) => {
      console.log('Response:', chainId);
    }).catch((error) => {
      if (error.code === 4001) {
        // EIP-1193 userRejectedRequest error
        console.log('Please connect to MetaMask.');
      } else {
        console.error(error);
      }
    });

를 참조하여 window.biport.request(args) 를 사용하세요.

Methods

wallet_getPermissions

요청자에게 현재 지갑의 권한 정보들을 가져옵니다.

window.biport.request({ method: 'wallet_getPermissions' })
    .then((result) => {
      console.log('Response:', result);
    });

지갑에서 DApp과 연결된 권한의 정보입니다. 요청자가 권한을 가지고 있지 않은 경우, 결과의 배열은 비어 있습니다.

wallet_requestPermissions

사용자로부터 권한을 요청합니다. 현재 eth_accounts 만 권한 요청이 필요합니다.

이 요청은 Biport 팝업을 트리거합니다. 권한을 요청하는 것은 사용자의 직접적인 액션(버튼 클릭 등)에 대한 응답으로만 요청해야 합니다.

window.biport
  .request({
    method: 'wallet_requestPermissions',
    params: [{ eth_accounts: {} }],
  })
  .then((permissions) => {
    const accountsPermission = permissions.find(
      (permission) => permission.parentCapability === 'eth_accounts'
    );
    if (accountsPermission) {
      console.log('eth_accounts permission successfully requested!');
    }
  })
  .catch((error) => {
    if (error.code === 4001) {
      // EIP-1193 userRejectedRequest error
      console.log('Permissions needed to continue.');
    } else {
      console.error(error);
    }
  });

wallet_switchEthereumChain

지정된 체인 ID를 가진 체인으로 전환하도록 사용자에게 확인 메시지를 만듭니다.

이 메소드는 사용자의 직접적인 액션(버튼 클릭 등)에 대한 응답으로만 호출해야 합니다.

다음 중 하나라도 해당되는 경우, Biport는 요청을 거부합니다.

  • 체인 ID가 올바르지 않음

  • 지정된 체인 ID를 가진 체인을 Biport가 지원하지 않음

이 메소드는 EIP-3326에 의해 정의됩니다.

  await biport.request({
    method: 'wallet_switchEthereumChain',
    params: [{ chainId: '0x5' }],
  });

wallet_watchAsset

이 메서드는 사용자가 Biport에서 지정된 토큰을 추적하도록 요청합니다.

이 메서드는 dapp 개발자가 런타임에서 사용자에게 지갑에서 토큰을 추적하도록 요청할 수 있도록 합니다.

이 메서드는 EIP-747에 의해 지정됩니다.

biport
  .request({
    method: 'wallet_watchAsset',
    params: {
      type: 'ERC20',
      options: {
        address: '0xb60e8dd61c5d32be8058bb8eb970870f07233155',
        symbol: 'FOO',
        decimals: 18,
        image: 'https://foo.io/token-image.svg',
      },
    },
  })
  .then((success) => {
    if (success) {
      console.log('FOO successfully added to wallet!');
    } else {
      throw new Error('Something went wrong.');
    }
  })
  .catch(console.error);

지원하지 않는 Methods

  • wallet_addEthereumChain

  • wallet_registerOnboarding

  • wallet_scanQRCode

위 RPC Method는 현재 지원하지 않습니다.

Ethereum JSON-RPC의 더 자세한 내용은 를 통해 확인할 수 있습니다.

🖨️
Ethereum Wiki
Ethereum Wiki
MetaMask API