This basic project shows an example on how to use the SafeWeb3Provider.
The Gnosis Safe Authenticator must be installed and configured.
Install dependencies
npm install
Build files to ./build
folder.
npm run build
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)
// ...
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 integrates safe-web3-provider
- Dapp is whitelisted
- Dapp integrates safe-web3-provider
- safe-web3-provider is injected by default. Local safe-web3-provider can be used if selected.
- Dapp integrates safe-web3-provider
- Dapp is not whitelisted
-
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.
- Dapp integrates safe-web3-provider
- Dapp is not whitelisted