@giacomo.licari/safe-apps-provider
v0.6.0
Published
A provider wrapper of Safe Apps SDK
Downloads
7
Readme
Safe Apps Provider
This is a provider that follows common standards (e.g. EIP-1193) and can be used with various Web3 libraries (e.g. Web3js or Ethers)
How to use
- Add npm package
yarn add @giacomo.licari/safe-apps-provider
npm i @giacomo.licari/safe-apps-provider
SafeAppProvider
The provider can be used with the safe-apps-react-sdk and common web3 libraries.
With Ethers.js
import React, { useMemo } from 'react';
import { ethers } from 'ethers';
import { useSafeAppsSDK } from '@giacomo.licari/safe-apps-react-sdk';
import { SafeAppProvider } from '@giacomo.licari/safe-apps-provider';
const App = () => {
const { sdk, safe } = useSafeAppsSDK();
const web3Provider = useMemo(() => ethers.providers.Web3Provider(new SafeAppProvider(safe, sdk)), [sdk, safe]);
// use provider with contracts
return;
};
export default App;
With Web3js
import React, { useMemo } from 'react';
import Web3 from 'web3';
import { useSafeAppsSDK } from '@giacomo.licari/safe-apps-react-sdk';
import { SafeAppProvider } from '@giacomo.licari/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;
More scenarios
For the SDK overview documentation, please refer to the safe-apps-sdk documentation