5. Full Example

In this example we use rainbowkit and wagmi libraries to manage Web3 connectivity, you might use any other library.

All of our UI libraries support both Javascript and Typescript environments.

Types, interfaces, helper functions, and object maps can be found in and imported from the @quadrata/core-react and @quadrata/kyb-react NPM packages.

import React, { useState } from 'react';
import { QuadClientEnvironment, QuadrataOnApplicationEndCallback } from '@quadrata/core-react';
import { PageKyb, QuadClientKybConfig, QuadrataKyb } from '@quadrata/kyb-react';

const quadKybConfig: QuadClientKybConfig = {
    apiUrl: 'https://prod.quadrata.com/api/v1',    // Testing url: https://int.quadrata.com/api/v1
    environment: QuadClientEnvironment.PRODUCTION, // Use QuadClientEnvironment.SANDBOX for testing environment
    protocolName: 'Your Company Name',
    _debug: false,  // set this to true if on a localhost domain
};

// Component
export const MyComponent: React.FC<{ accessToken: string }> = ({
  accessToken,
}) => {
    const [showModal, setShowModal] = useState<boolean>(false);

    // Handlers
    const handleOnApplicationEnd: QuadrataOnApplicationEndCallback = ({ status, error }) => {
        // Application has reached an end state: completion or error
        console.log('handleOnApplicationEnd:::status:::', status);
        console.log('handleOnApplicationEnd:::error:::', error);
    };
  
    const handleOnHide = () => {
        // do something on QuadrataKyb client hide
    };

    const handlePageChange = (page: PageKyb) => {
        // do something on page change
    };
    
    if (!showModal) {
        // Button to launch the KYB application
        return (
            <button
                type="button"
                onClick={() => setShowModal(true)}
            >
                Launch Quadrata
            </button>
        );
    }

    return (
        <QuadrataKyb
            accessToken={accessToken}
            config={quadKybConfig}
            onApplicationEnd={handleOnApplicationEnd}
            onHide={handleOnHide}
            onPageChange={handlePageChange}
        />
    );
};

Last updated