useBusinessDetails
useBusinessDetails Hook¶
The useBusinessDetails hook lets you check whether a given blockchain address is a business user (i.e. has business permission) by reading the on-chain state. And also tell business contract address and business details
import React from "react";
import { useBusinessDetails } from "@redbellynetwork/eligibility-sdk";
const BusinessPermissionStatus: React.FC<{ businessAddress: string }> = ({
businessAddress,
}) => {
const { data, error, isLoading, refetchBusinessIdentifier } =
useBusinessDetails(businessAddress);
if (isLoading) return <p>Loading...</p>;
if (error) return <p>Error: {error.message}</p>;
return (
<div>
{data?.isBusinessUser ? (
<p>Business user {businessAddress} is allowed.</p>
<p>Business contract address: {data?.businessContractAddress}</p>
<p>Business Information: {data?.businessDetails}</p>
) : (
<p>Business user {businessAddress} is not allowed.</p>
)}
</div>
);
};
export default BusinessPermissionStatus;
Parameters¶
• address (string):¶
The blockchain address to check for business permission and business details.
Return Value¶
The hook returns the object provided by useReadContract, which includes:
• data:¶
The response from the contract call. Typically, this is a object that contains field:-
isBusinessUser
this is a boolean indicating if the address is allowed.businessContractAddress
this is the contract address of Business contract of the company of which user is part of.businessDetails
this is the object that contains information of business, when Business contract deployed it contains company name, identifier, identifier type, incorporated name, is beneficial owner, company address
• isLoading:¶
A boolean that is true while the contract call is in progress.
• error:¶
An error object if the call fails; otherwise, undefined.
• refetchBusinessIdentifier:¶
A function to manually trigger a re-fetch of the contract state.