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

0.0.3 • Public • Published

Credenza3 Ads

Dependencies

Credenza Passport

Installation

with npm

npm install @credenza-web3/ads

with yarn

yarn add @credenza-web3/ads

with pnpm

pnpm install @credenza-web3/ads

or include a script tag

<script src="https://cdn.jsdelivr.net/npm/@credenza-web3/ads/dist/ads.umd.js"></script>
<script>
  const Ads = window.CredenzaAds
</script>

or with esm

<script type="module">
  import {Ads} from 'https://cdn.jsdelivr.net/npm/@credenza-web3/ads/+esm'
</script>

Usage

Create the Ads instance

const ads = new Ads(passport) // instance of credenza passport

Static

Ads.ContractTypes (object) Current package version

Methods

activate

const id = ads.activate({
  querySelector: '#container',
  // triggers when the ad is clicked. Returns the rule if matched.
  onClick: ({isRuleMatched: boolean, rule?: Rule }) => {
    console.log(isRuleMatched, rule);
  },
  // default images for logged in /logged out users
  basicImages: {
    loggedIn: string, //url
    loggedOut: string //url
  },
  // blockchain rules to check sequentially
  rules: [{
    contractType: Ads.ContractTypes['SELECTED_TYPE'],
    contractAddress: string,
    value: string // JSON.stringify({tokenId: '1', amount: '1'}) for 1155
    image: string //url. Displays if rule matches.
  }]
})

deactivate

ads.deactivate(id)

/@credenza-web3/ads/

    Package Sidebar

    Install

    npm i @credenza-web3/ads

    Weekly Downloads

    0

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    1.26 MB

    Total Files

    13

    Last publish

    Collaborators

    • mike.avvad
    • credenza
    • fokindmitr