@credenza-web3/ads
v0.0.3
Published
Credenza Scanner
Downloads
7
Readme
Credenza3 Ads
Dependencies
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)