Safe Apps React SDK
This sdk should provide a simple way to write a React.js Safe app
How to use
yarn add @rmeissner/safe-apps-react-sdk
- Add
SafeProvider
Safe provider accepts loader
and options
props
import SafeProvider from '@rmeissner/safe-apps-react-sdk';
ReactDOM.render(
<React.StrictMode>
<SafeProvider>
<App /> // Your app
</SafeProvider>
</React.StrictMode>,
document.getElementById('root'),
);
import { useSafeAppsSDK } from '@rmeissner/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',
},
];
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