@giacomo.licari/safe-apps-react-sdk
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

Safe Apps React SDK

npm

This sdk should provide a simple way to write a React.js Safe app

How to use

  • Add npm package
yarn add @giacomo.licari/safe-apps-react-sdk

npm i @giacomo.licari/safe-apps-react-sdk
  • Add SafeProvider
    Safe provider accepts loader and options props
// ... other imports
import SafeProvider from '@giacomo.licari/safe-apps-react-sdk';

ReactDOM.render(
  <React.StrictMode>
    <SafeProvider>
      <App /> // Your app
    </SafeProvider>
  </React.StrictMode>,
  document.getElementById('root'),
);
  • Use Safe Apps SDK Hook
// ... other imports
import { useSafeAppsSDK } from '@giacomo.licari/safe-apps-react-sdk';

const App = () => {
  const { sdk, connected, safe } = useSafeAppsSDK();
  return <div>{safe.safeAddress}</div>;
};

Usages

Send transactions

const txs: Transaction[] = [
  {
    to: '0x31415629...',
    value: '0',
    data: '0xbaddad',
  },
  //...
];
// Returns a hash to identify the Safe transaction
const safeTxHash: string = await sdk.txs.send({ txs });

Load Safe transaction information

const safeTx: SafeTransaction = await sdk.txs.getBySafeTxHash(safeTxHash);

More scenarios

For all available sdk methods, please refer to the safe-apps-sdk documentation

Readme

Keywords

none

Package Sidebar

Install

npm i @giacomo.licari/safe-apps-react-sdk

Weekly Downloads

1

Version

4.0.0

License

MIT

Unpacked Size

7.57 kB

Total Files

5

Last publish

Collaborators

  • giacomo.licari