Menu Close

use-delegatecash

use-delegatecash

⚛️ 💸 React.js hooks for delegate.cash which enable you to build safer user experiences powered by asset delegation. Supports both React and React Native.

🚀 Getting Started

To get started, make sure you’ve got the following dependencies installed:

yarn add ethers wagmi use-delegatecash

💭 use-delegatecash assumes you’ve already declared a WagmiConfig at the root of your application.

✍️ Usage

use-delegatecash wraps all of the getter functions exported by delegatecash inside stateful typesafe React hooks.

You can also useDelegateCash() to return a DelegateCash object, which can be used to initiate transactions.

import * as React from 'react'; import { ActivityIndicator, StyleSheet, Text, View, } from 'react-native'; import { useCheckDelegateForAll, useGetDelegatesForContract, useCheckDelegateForContract, useCheckDelegateForToken, useDelegateCash, useGetContractLevelDelegations, useGetDelegatesForAll, useGetDelegatesForContract, useGetDelegationsByDelegate, useGetTokenLevelDelegations, isDelegateCashResult, isDelegateCashError, } from 'use-delegatecash'; export const AppExample = React.memo( function AppExample(): JSX.Element { const state = useGetDelegatesForAll({ vault: '0x312e71162Df834A87a2684d30562b94816b0f072', }); return ( <View style={[StyleSheet.absoluteFill, styles.center]}> {isDelegateCashError(state) ? <Text children={state.error.message} /> : isDelegateCashResult(state) ? <Text children="Got result!" /> : <ActivityIndicator />} </View> ); }, ); const styles = StyleSheet.create({ center: {alignItems: 'center', justifyContent: 'center'}, });

✌️License

MIT

View Source Code
Posted in Development