Multibase JS SDK (@multibase/js)
Multibase JS is the first JavaScript SDK for merging your user off-chain, product interactions with on-chain transactions and activity.
Table of contents
✅ Getting started
Get a Multibase account
To use the Multibase JS SDK, the first thing you have to do is sign up for a Mutlibase account. Go to the homepage and fill out our form, and we will get back to you ASAP to get you set up.
Install the Node Package
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
💻 Usage
Initialize the SDK
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)
Identify users
To associate product events with users, you have to use the identify
function.
Identify by wallet
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({
address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
})
// Identify with properties
const userProperties = {
plan: "Premium User",
email: "vitalik@ethereum.org"
}
identify({
address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
properties: userProperties
})
Track events
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 and 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
const eventProperties = {
type: "Call to Action",
timeToClick: 10
}
track("Link Click", eventProperties)
❓ Feedback and Support
If you are having trouble setting up the Multibase SDK at all, please reach out to us for help. Here are some helpful links: