This is a provider that follows common standards (e.g. EIP-1193) and can be used with various Web3 libraries (e.g. web3.js or Ethers)
- Add npm package
yarn add @gnosis.pm/safe-apps-provider
npm i @gnosis.pm/safe-apps-provider
The provider can be used with the safe-apps-react-sdk and common web3 libraries.
import React, { useMemo } from 'react';
import { ethers } from 'ethers';
import { useSafeAppsSDK } from '@gnosis.pm/safe-apps-react-sdk';
import { SafeAppProvider } from '@gnosis.pm/safe-apps-provider';
const App = () => {
const { sdk, safe } = useSafeAppsSDK();
const web3Provider = useMemo(() => new ethers.providers.Web3Provider(new SafeAppProvider(safe, sdk)), [sdk, safe]);
// use provider with contracts
return;
};
export default App;
import React, { useMemo } from 'react';
import Web3 from 'web3';
import { useSafeAppsSDK } from '@gnosis.pm/safe-apps-react-sdk';
import { SafeAppProvider } from '@gnosis.pm/safe-apps-provider';
const App = () => {
const { sdk, safe } = useSafeAppsSDK();
const web3Provider = useMemo(() => new Web3(new SafeAppProvider(safe, sdk)), [sdk, safe]);
// use provider with contracts
return;
};
export default App;
For the SDK overview documentation, please refer to the safe-apps-sdk documentation