Git Product home page Git Product logo

example-safe-web3-provider's Introduction

example-safe-web3-provider

This basic project shows an example on how to use the SafeWeb3Provider.

The Gnosis Safe Authenticator must be installed and configured.

Installation

Install dependencies

npm install

Build

Build files to ./build folder.

npm run build

Usage of the safe-web3-provider

import Web3 from 'web3'
import SafeProvider from 'safe-web3-provider'

/**
 *  Create Safe Provider
 */
const provider = new SafeProvider({
  rpcUrl: 'http://localhost:8545'
})

/**
 *  Create Web3
 */
const web3 = new Web3(provider)

/**
 *  Get Accounts
 */
const accounts = await web3.eth.getAccounts()

/**
 * Send Transaction
 */
const txHash = await web3.eth.sendTransaction(tx)

// ...

Dapp interaction

Dapps like this one must be whitelisted in the Gnosis Safe Authenticator in order to have full access to the provider.

Different situations:

  • Only Gnosis Safe Authenticator is installed

    • Dapp is not whitelisted
      • Dapp integrates safe-web3-provider
        • Dapp is unusable. Local safe-web3-provider is empty (no Safe account data and pop-up never opens).
    • Dapp is whitelisted
      • Dapp integrates safe-web3-provider
        • safe-web3-provider is injected by default. Local safe-web3-provider can be used if selected.
  • Both Gnosis Safe Authenticator and Metamask are installed

    • Dapp is not whitelisted
      • Metamask is used
    • Dapp is whitelisted
      • Dapp integrates safe-web3-provider
        • Local safe-web3-provider is used.

example-safe-web3-provider's People

Contributors

germartinez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.