Skip to content
项目

coinbase/coinbase-wallet-sdk

在 GitHub 查看

关于

一种开放协议,让用户可以将移动钱包连接到你的 DApp。

商业与金融

这些数字如何统计

实测星标增长

24小时
+1
7天
+5
15天
+8
1个月
+10

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Coinbase Wallet SDK

npm

Overview

The Coinbase Wallet SDK connects your app to Coinbase Wallet so it can interact with the Ethereum blockchain.

  1. Coinbase Wallet

Installing the SDK

# npm
npm install @coinbase/wallet-sdk

# yarn
yarn add @coinbase/wallet-sdk

SDK Setup and Usage

Upgrading the SDK

  1. Compare the installed version with the latest:

    # yarn
    yarn outdated @coinbase/wallet-sdk
    
    # npm
    npm outdated @coinbase/wallet-sdk
    
  2. Update to latest:

    # yarn
    yarn upgrade @coinbase/wallet-sdk --latest
    
    # npm
    npm update @coinbase/wallet-sdk
    

Basic SDK Usage

  1. Initialize the SDK

    const sdk = createCoinbaseWalletSDK({
      appName: 'SDK Playground',
    });
    
  2. Make Coinbase Wallet Provider

    const provider = sdk.evm.getProvider();
    
  3. Request accounts to initialize a connection to wallet

    const addresses = provider.request({
      method: 'eth_requestAccounts',
    });
    
  4. Make more requests

    provider.request('personal_sign', [
      `0x${Buffer.from('test message', 'utf8').toString('hex')}`,
      addresses[0],
    ]);
    
  5. Handle provider events

    provider.on('connect', (info) => {
      setConnect(info);
    });
    
    provider.on('disconnect', (error) => {
      setDisconnect({ code: error.code, message: error.message });
    });
    
    provider.on('accountsChanged', (accounts) => {
      setAccountsChanged(accounts);
    });
    
    provider.on('chainChanged', (chainId) => {
      setChainChanged(chainId);
    });
    
    provider.on('message', (message) => {
      setMessage(message);
    });
    

Developing locally and running the test app

探索相关项目

加载中…