JSPM

@walletconnect/web3-provider

1.0.0-beta.4
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 26514
    • Score
      100M100P100Q15258F
    • License LGPL-3.0

    Web3 Provider for WalletConnect

    Package Exports

    • @walletconnect/web3-provider

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@walletconnect/web3-provider) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    WalletConnect Web3 Provider

    Web3 Provider for WalletConnect

    For more details, read the documentation

    Example

    import Web3 from "web3";
    import WalletConnectProvider from "walletconnect-web3-provider";
    
    /**
     *  Create WalletConnect Provider
     */
    const provider = new WalletConnectProvider({
      bridge: "https://test-bridge.walletconnect.org", // Required
      rpcUrl: "http://localhost:8545" // Required
    });
    
    /**
     *  Create Web3
     */
    const web3 = new Web3(provider);
    
    /**
     *  Get Accounts
     */
    const accounts = await web3.eth.getAccounts();
    
    if (!accounts.length) {
      // Display QR Code URI
      const uri = web3.currentProvider.walletconnect.uri;
    
      // Create a new session
      await web3.currentProvider.walletconnect.createSession();
    
      // Get Accounts Again
      accounts = await web3.eth.getAccounts();
    }
    
    /**
     * Send Transaction
     */
    const txHash = await web3.eth.sendTransaction(tx);
    
    /**
     * Sign Transaction
     */
    const signedTx = await web3.eth.signTransaction(tx);
    
    /**
     * Sign Message
     */
    const signedMessage = await web3.eth.sign(msg);
    
    /**
     * Sign Typed Data
     */
    const signedTypedData = await web3.eth.signTypedData(msg);