Examples

Instructions for setting up HUDI SDK on your platform. Explore coding examples to kickstart your integration.

Easily integrate the HUDI SDK by copying and pasting the provided code into your website’s head tag. Interact with users' Data Wallets through methods for writing, reading, and managing data securely within the HUDI ecosystem.

Follow practical examples to understand how to write, read, and interact with data within the HUDI ecosystem. These examples provide step-by-step guidance to help you integrate HUDI's Data Wallet into your applications, ensuring secure data transactions.

Setup

First of all the SDK setup, just copy and paste this code in your website head tag. That's it.

<script>
! function(h, u, d, i) {
        i = h.document.createElement(d);
        i.async = !0;
        i.src = 'https://asset.humandataincome.com/sdk/index.js';

        u.getElementsByTagName(d)[0].parentNode.prepend(i);

        for (let j of ['hdw', 'hdr', 'hdn', 'hdl']) {
          if (!h[j]) {
            h[j] = (a) => h[j].m ? h[j].m(a) : h[j].q.push(a);
            h[j].q = []
          }
        }
      }(window, document, 'script');
</script>

Now you can interact with the visitor user data wallet with three methods that will be discussed now.

Write

window.hdw({
 data: [
   {
     path: 'profile.personal',
     value: {
       firstName: 'Andrea',
       lastName: 'Silvi',
       email: 'andrea@humandataincome.com'
     }
   },
   {
     path: 'profile.demographic',
     value: {
       career: 'Engineer',
     }
   }
 ],
 dismiss: () => {}
})

Read

In order to read from the user data wallet you can invoke this method.

window.hdr({
  data: [
    {
      path: 'app#humandataincome#com.profile.personal',
      required: false,
    },
    {
      path: 'app#humandataincome#com.profile.demographic',
    },
  ],
  dismiss: () => {},
  response: (data) => {
    console.log('response', data);
  }
})

Last updated