wallets.setPrimary() method on the dynamic client.
You can access the current primary wallet and switch to a different one using the reactive client:
React Native
wallets.setPrimary() method on the dynamic client.
You can access the current primary wallet and switch to a different one using the reactive client:
import { FC } from 'react';
import { dynamicClient } from '<path to client file>';
import { useReactiveClient } from '@dynamic-labs/react-hooks';
import { View, Text, TouchableOpacity } from 'react-native';
const SetFirstWalletRN: FC = () => {
const { wallets } = useReactiveClient(dynamicClient);
return (
<View>
<Text>Current primary wallet: {wallets.primary?.address}</Text>
<TouchableOpacity
onPress={() => wallets.setPrimary({ walletId: wallets.userWallets[0].id })}
>
<Text>Set first wallet as primary</Text>
</TouchableOpacity>
</View>
);
};
Was this page helpful?