Commands
Share Contacts
Sharing contacts is a command that allows you to request users to share contacts in their phone in a privacy preserving way. This command will be available from v1.4.0 of minikit and v2.8.72 of World App.
Crafting the payload
export type ShareContactsInput = {
isMultiSelectEnabled: boolean;
inviteMessage?: string;
}
isMultiSelectEnabled
is a boolean that determines if the user can select multiple contacts, by default you can only select one contact in the modal.inviteMessage
is an optional custom message that will be displayed to the user when the user invites a non world app user while inside of your mini app.
Using the command
Here is an example of how to use the shareContacts command.
Async handlersEvent listeners
Sending the command and handling the response
// Example function of how to use the command
const shareContacts = useCallback(
async (isMultiSelectEnabled: boolean = false, inviteMessage?: string) => {
const shareContactsPayload: ShareContactsPayload = {
isMultiSelectEnabled,
inviteMessage,
};
const payload = await MiniKit.commandsAsync.shareContacts(shareContactsPayload);
// Handle the response
},
[]
);
Response type
The response will contain an array of contacts that the user has selected.
Success response payload
type MiniAppShareContactsSuccessPayload = {
status: 'success';
contacts: Array<{
username: string;
walletAddress: string;
profilePictureUrl: string | null;
}>;
timestamp: string;
version: number;
};
Error response payload
type MiniAppShareContactsErrorPayload = {
status: 'error';
error_code: ShareContactsErrorCodes;
version: number;
}
The possible error codes are:
user_rejected
- The user rejected the requestgeneric_error
- An unknown error occurred