Multibase JS is the first JavaScript SDK for merging your user off-chain, product interactions with on-chain transactions and activity.
To use the Multibase JS SDK, the first thing you have to do is sign up for a Multibase account. Go to the homepage and fill out our form, and we will get back to you ASAP to get you set up.
When you have your account, you're ready to go! To get started with using Multibase JS, you'll need to install the package to your project with NPM/yarn.
# npm
npm install @multibase/js
# yarn
yarn add @multibase/js
Multibase JS must be initialized before you can call any function. You will need your Multibase project's write API key.
import { init } from "@multibase/js"
init(YOUR_WRITE_API_KEY)
To associate product events with users, you have to use the identify
function.
To connect a user by their on-chain address, we must provide an address
parameter.
When you identify user by wallet address, they will automatically be synchronized in your Multibase workspace. Upon import, Multibase will sync all on-chain data on every chain where a user has sent at least one transaction.
import { identify } from "@multibase/js"
// Basic identifying call
identify("0xd8da6bf26964af9d7eed9e03e53415d37aa96045")
// Identify with properties
identify("0xd8da6bf26964af9d7eed9e03e53415d37aa96045", {
plan: "Premium User",
email: "vitalik@ethereum.org"
})
Tracking product events from your users is the key to understanding product usage over time, and understanding how off-chain activity converts to on-chain transactions. You can track an event with a custom string, or you can track properties along with the string.
In your Multibase dashboard, these events will appear alongside on-chain events.
import { track } from "@multibase/js"
// Basic tracking call
track("Link Click")
// Track with event properties
track("Link Click", {
type: "Call to Action",
timeToClick: 10
})
If you are having trouble setting up the Multibase SDK at all, please reach out to us for help. Here are some helpful links: