Webaverse

Webaverse

    ›API

    Webaverse

    • Overview
    • SILK
    • NFTs
    • Avatars
    • Parcels
    • Seasons
    • Discord Bot
    • Twitter Bot
    • Guides

      • Getting Started In Webaverse

    Market

    • How To Get SILK
    • How To Buy And Sell NFTs
    • How To Trade

    Create

    • Overview
    • How To Mint NFTs
    • How To Mint NFTs in Discord
    • Season 0: Genesis

      • Submission Guide

      Avatars

      • Import From VRoid Studio

      3D Models

      • Import From Blender
      • Bake Physics For 3D Model
      • Export Multiple Animations

      Voxels

      • Import From MagicaVoxel

      XRPackage

      • What is XRPackage?
      • Create An XRPackage
      • Design Guidelines
      • Add Monetization
      • Examples

      API

      • Runtime API
      • Manifest API
      • Monetization API

    Monetization API

    The Monetization API allows you to lock or unlock content in your XRPackage based on whether a user has Web Monetization enabled or if they are a NFT owner of your XRPackage.

    For a step-by-step guide on how to implement this API in your app, checkout Create An XRPackage.

    Document.monetization

    The browser exposes the document.monetization DOM object that implements EventTarget and has a read-only state property.

    The object allows you to track Monetization events and see whether the user has web monetization enabled or is a NFT owner of your XRPackage.

    document.monetization: EventTarget
    document.monetization.state: 'stopped' | 'started'
    

    States

    Check the value of document.monetization.state to see if a user is has web monetization enabled or is a NFT owner of your XRPackage.

    stopped

    The user is not currently an NFT owner of your XRPackage and does not have Web Monetization enabled.

    document.monetization.state === 'stopped'
    

    started

    The user is an NFT owner of your XRPackage or has Web Monetization enabled and Webaverse is currently sending micropayments.

    document.monetization.state === 'started'
    

    Browser events

    monetizationstart

    Determine when Monetization has started by adding an event listener for monetizationstart to document.monetization.

    Event listener

    function startEventHandler (event) {
      console.log(event)
    }
    
    document.monetization.addEventListener('monetizationstart', startEventHandler)
    

    monetizationstop

    Determine when Monetization has stopped by adding an event listener for monetizationstop to document.monetization.

    Event listener

    function stopEventHandler (event) {
      console.log(event)
    }
    
    document.monetization.addEventListener('monetizationstop', stopEventHandler)
    
    Last updated on 12/15/2020
    ← Manifest API
    • Document.monetization
    • States
      • stopped
      • started
    • Browser events
      • monetizationstart
      • monetizationstop
    Docs
    OverviewCreate Overview
    Community
    DiscordTwitter
    More
    WebaverseGitHub
    © 2021 Webaverse