@moojo/moojo-ads-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.47 • Public • Published

Moojo Ads SDK

This README provides instructions on how to use the Moojo Ads SDK for displaying ads in your application.

Installation

The Moojo Ads SDK is available on npm. You can install it using npm or yarn:

npm install @moojo/moojo-ads-sdk
# or
yarn add @moojo/moojo-ads-sdk

Usage

Initialize Moojo Ads

To initialize the MoojoAdsSDK, you need to provide the following parameters:

Parameter Description Required
userPrivateKey The user's private key, a unique identifier used to encrypt their data. Yes
appWalletAddress Your application's private wallet address, used to collect your revenue share. Yes
options Configuration options (network, debug mode). No

Generating User Keys

Moojo generates the user's private key using their unique identifier. Use your internal user ID in the following way:

import { MoojoAdsSdk, userKeys, PrivateKey } from '@moojo/moojo-ads-sdk'

const INTERNAL_USER_ID = '4343' // Replace with your own internal ID
const userPrivateKey = userKeys.privateKeyForSecret(INTERNAL_USER_ID)
const publicKey = privateKey.createPublic()

Note: The internal user ID should remain confidential and consistent for each user across login sessions.

Initializing the SDK

After obtaining the user's key, initialize the SDK:

import { MoojoAdsSdk, userKeys, PrivateKey } from '@moojo/moojo-ads-sdk'

// Setting up your dApp wallet address
const appWalletAddress = '0x1234...' // Replace with your own wallet address

// Create an instance of MoojoAdsSdk
const moojoAdsSdk = new MoojoAdsSdk(userPrivateKey, appWalletAddress, {
  network: 'mainnet',
  debug: false,
})

Retrieving Matching Ads

To load all ads that match the current user:

const matchingAds = await moojoAdsSdk.listAds()

Filtering and Displaying Ads

To loop through the list of ads and, for example, print names of 'native' ads:

const matchingAds = await moojoAdsSdk.listAds()

matchingAds.filter(ad => ad.tag === 'native').forEach(ad => console.log(ad.name))

Configuration Options

When initializing the SDK, you can provide the following options:

  • network: 'testnet' or 'mainnet'
  • debug: true or false

Additional Information

For more detailed information about the Moojo Ads SDK, please refer to our official documentation.

License

This project is licensed under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i @moojo/moojo-ads-sdk

Weekly Downloads

9

Version

0.1.47

License

MIT

Unpacked Size

2.73 MB

Total Files

61

Last publish

Collaborators

  • romangol
  • ommoojo
  • rotemrd
  • unglik
  • imaman
  • imaman-moojo
  • shelly-moojo
  • jonny-moojo