npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

test-ad-sdk

v0.0.6

Published

test ad SDK: A modular, open-source TypeScript SDK for integrating adbazaar ads

Downloads

3

Readme

SDK Integration Guide

Welcome to the SDK Integration Guide! This document will help you get started with integrating our SDK into your project.

Table of Contents

Introduction

This Adbazaar SDK allows publishers to display adds on there respective websites by integrating our get advertisement features into their website. With our SDK, you can:

  • Get Advertisement
  • Advertisements shown based on the profile of the user(coming from third party service linkko)

Requirements

Before you begin, ensure you have the following prerequisites:

  • Node.js (v16 or above)
  • Node package manager (for installing node dependencies)
  • Internet connection

Installation

For intalling the sdk on your machine use the below command :

npm i test-ad-sdk

Once the installation is successfull you are ready to configure the package

Configuration

Configure the arguments passed to the getAdvertisement function Here are the list of arguments passed to the getAdvertisement

  • publisherContractAddress : The contract address of the publisher
  • adSpaceId : The adSpace on which the publisher wants the ads to be displayed
  • userWalletAddress : The wallet address of the user for which the ads has to be shown(note : this address is used for fetching the user profile from linkko)

Usage

Here is step by step guide for usage:

  1. Import the package using the import statement
import { getAdvertisement } from 'test-ad-sdk';
  1. Now configure the getAdvertisement variables accordingly
const publisherContractAddress  = 'your_publisher_contract_address'
const adSpaceId = 'your_ad_space_id'
const userWalletAddress = 'your_user_wallet_address'
  1. Call the getAdvertisement function from the sdk to get the ads
const result : any = await getAdvertisement(publisherContractAddress, adSpaceId, userWalletAddress)
return result
  1. Call the getAdvertisementBySize function from sdk to get the imageUrl by providing the respective dimension.
const result : any = await getAdvertisementBySize(publisherContractAddress, adSpaceId, dimension, userWalletAddress)
return result

Usage Summary

  1. Usage summary to fetch getAdvertisement.
import { getAdvertisement } from'test-ad-sdk'; 
const publisherContractAddress = 'your_publisher_contract_address';
const adSpaceId = 'your_ad_space_id';
const userwalletAddress = 'your_user_wallet_address';

async function fetchAdvertisement(): Promise<any> {
    try {
        const result: any = await getAdvertisement(publisherContractAddress, adSpaceId, userwalletAddress);
        return result;
    } catch (error) {
        throw error;
    }
}

// Example Usage
fetchAdvertisement()
    .then(result => {
        console.log("Advertisement fetched successfully:", result);
    })
    .catch(error => {
        console.error("Failed to fetch advertisement:", error);
    });

NOTE: To export the fetchAdvertisement function using export default in TypeScript, you can modify the function definition and export statement accordingly.

import { getAdvertisement } from 'test-ad-sdk';

const publisherContractAddress = 'your_publisher_contract_address';
const adSpaceId = 'your_ad_space_id';
const userwalletAddress = 'your_user_wallet_address';

async function fetchAdvertisement(): Promise<any> {
    try {
        const result: any = await getAdvertisement(publisherContractAddress, adSpaceId, userwalletAddress);
        console.log("selected ad details", result);
        return result;
    } catch (error) {
        console.error("Error fetching advertisement:", error);
        throw error;
    }
}

export default fetchAdvertisement;
  1. Usage summary to fetch getAdvertisementBySize.
import { getAdvertisementBySize } from'test-ad-sdk'; 
const publisherContractAddress = 'your_publisher_contract_address';
const adSpaceId = 'your_ad_space_id';
const userwalletAddress = 'your_user_wallet_address';
const dimension = 'your_dimension'   //e.g '300x250'

async function fetchAdvertisementBySize(): Promise<any> {
    try {
        const result: any = await getAdvertisementBySize(publisherContractAddress, adSpaceId, dimension, userwalletAddress);
        return result;
    } catch (error) {
        throw error;
    }
}

// Example Usage
fetchAdvertisementBySize()
    .then(result => {
        console.log("ImageUrl fetched successfully:", result);
    })
    .catch(error => {
        console.error("Failed to fetch advertisementBySize:", error);
    });

Output

  • Sample output of getAdvertisement function
  {
      adDetails: {
        '0': {
          deviceType: 1,
          dimension: '320x100',
          ipfsUrl: 'ipfs.io/ipfs/QmPw3gQMK73CeVD3fVstHicH51cy5bnG4wJKji6tuyBL7Y/Banner%20320x100.png'
        },
        '1': {
          deviceType: 1,
          dimension: '728x90',
          ipfsUrl: 'ipfs.io/ipfs/QmPw3gQMK73CeVD3fVstHicH51cy5bnG4wJKji6tuyBL7Y/Nike%20Leaderboard%20728x90.png'
        },
        '2': {
          deviceType: 1,
          dimension: '300x250',
          ipfsUrl: 'ipfs.io/ipfs/QmPw3gQMK73CeVD3fVstHicH51cy5bnG4wJKji6tuyBL7Y/Nike%20Medium%20Rectangle%20300x250.png'
        },
        '3': {
          deviceType: 1,
          dimension: '120x600',
          ipfsUrl: 'ipfs.io/ipfs/QmPw3gQMK73CeVD3fVstHicH51cy5bnG4wJKji6tuyBL7Y/Nike%20Skycraper%20120x600_2.png'
        },
        advertiser: '0x659bC276EfCD11e42627ee4A2A47A38CF59E6da9',
        adTitle: 'Stack Overflow: AI',
        adText: 'AI power your knowledge community',
        adStatus: 1,
        payRatePerSecond: 57870370370370n,
        adLink: 'https://stackoverflow.co/teams/ai/?utm_medium=ppc&utm_source=house-ads&utm_campaign=teams-overflowai-launch',
        adSpaceSizes: [
          '0x3132307836303000000000000000000000000000000000000000000000000000',
          '0x3332307831303000000000000000000000000000000000000000000000000000',
          '0x3732387839300000000000000000000000000000000000000000000000000000',
          '0x3438307836300000000000000000000000000000000000000000000000000000',
          '0x3330307832353000000000000000000000000000000000000000000000000000'
        ],
        walletPersonas: [ 'Rewards' ],
        adId: '0xe038abb0d09d86ac5b16a2a78138a5400e30ea65316108b41ee268df23023cb9',
        balance: 74745486111111848740n,
        weight: 100
      }
    }

NOTE: In the above output use the ipfsUrl for displaying the ads with different ad dimensions.

  • Sample output of getAdvertisementBySize function
    • If the image with provided dimension exists

      {
          adDetails: {
              imageUrl: 'ipfs.io/ipfs/QmPw3gQMK73CeVD3fVstHicH51cy5bnG4wJKji6tuyBL7Y/Nike%20Medium%20Rectangle%20300x250.png'
            }
        }
    • If the image with provided dimension doesn't exists

      {
            adDetails: {
              '0': {
                deviceType: 1,
                dimension: '320x100',
                ipfsUrl: 'ipfs.io/ipfs/QmPw3gQMK73CeVD3fVstHicH51cy5bnG4wJKji6tuyBL7Y/Banner%20320x100.png'
              },
              '1': {
                deviceType: 1,
                dimension: '728x90',
                ipfsUrl: 'ipfs.io/ipfs/QmPw3gQMK73CeVD3fVstHicH51cy5bnG4wJKji6tuyBL7Y/Nike%20Leaderboard%20728x90.png'
              },
              '2': {
                deviceType: 1,
                dimension: '300x250',
                ipfsUrl: 'ipfs.io/ipfs/QmPw3gQMK73CeVD3fVstHicH51cy5bnG4wJKji6tuyBL7Y/Nike%20Medium%20Rectangle%20300x250.png'
              },
              '3': {
                deviceType: 1,
                dimension: '120x600',
                ipfsUrl: 'ipfs.io/ipfs/QmPw3gQMK73CeVD3fVstHicH51cy5bnG4wJKji6tuyBL7Y/Nike%20Skycraper%20120x600_2.png'
              },
              advertiser: '0x659bC276EfCD11e42627ee4A2A47A38CF59E6da9',
              adTitle: 'Stack Overflow: AI',
              adText: 'AI power your knowledge community',
              adStatus: 1,
              payRatePerSecond: 57870370370370n,
              adLink: 'https://stackoverflow.co/teams/ai/?utm_medium=ppc&utm_source=house-ads&utm_campaign=teams-overflowai-launch',
              adSpaceSizes: [
                '0x3132307836303000000000000000000000000000000000000000000000000000',
                '0x3332307831303000000000000000000000000000000000000000000000000000',
                '0x3732387839300000000000000000000000000000000000000000000000000000',
                '0x3438307836300000000000000000000000000000000000000000000000000000',
                '0x3330307832353000000000000000000000000000000000000000000000000000'
              ],
              walletPersonas: [ 'Rewards' ],
              adId: '0xe038abb0d09d86ac5b16a2a78138a5400e30ea65316108b41ee268df23023cb9',
              balance: 55766261574074933170n,
              weight: 100,
              imageUrl: null
            }
          }

References

Below are the screenshot of references to get the following parameters:

const publisherContractAddress  = 'your_publisher_contract_address'
const adSpaceId = 'your_ad_space_id'
const userWalletAddress = 'your_user_wallet_address'
  1. Visit the website https://adbazaar.vercel.app/

  2. Once you are on the website select Enter as a Publisher.

Alt text

  1. Now select ManageAdspace.

Alt text

  1. Now copy the publisherContractAddress and adSpaceId from the clipboard

Alt text

NOTE: For user wallet address provide the wallet address that you are using to show the ads on.

Contact

For further assistance, please reach out to our support team.