Darkblock React Polygon Widget

Getting Started 🚀

Install Darkblock's React Polygon Widget using yarn or npm

Copy
Copied
yarn add @darkblock.io/matic-widget
Copy
Copied
npm i @darkblock.io/matic-widget --save

Once the library is installed, import or require components into your codebase, i.e:

Copy
Copied
import PolygonDarkblockWidget from "@darkblock.io/matic-widget"

Polygon Widget Component

Input

  • contractAddress: contractAddress
  • tokenId: id of the NFT in Polygon
  • w3:* web3 object
  • cb: callback function to be triggered on the widget's state change (optional)
  • config: config object (optional)

cb function example, the callback function will have the widget's state passed as a parameter:

Copy
Copied
const cb = (param) => {
  console.log(param)
}

config object's default value:

Copy
Copied
{
  customCssClass: "",             // pass here a class name you plan to use
  debug: false,                   // debug flag to console.log some variables
  imgViewer: {                    // image viewer control parameters
    showRotationControl: true,
    autoHideControls: true,
    controlsFadeDelay: true,
  },
}

Example

Copy
Copied
import { PolygonDarkblockWidget } from "@darkblock.io/matic-widget"

const Widget = () => {
  ...

  const contractAddress = 'nft contract address'
  const tokenId = 'nft token id'

  return (
    <PolygonDarkblockWidget
      contractAddress={contractAddress}
      tokenId={tokenId
      w3={web3}
      cb={(p) => console.log(p)}
      config={config}
    />
  )
}

export default Widget

Example

Copy
Copied
import { PolygonUpgradeWidget } from "@darkblock.io/matic-widget"

const Widget = () => {
  const apiKey = '** contact darkblock for apikey **'
  const contractAddress = 'nft contract address'
  const tokenId = 'nft token id'

  return (
    <PolygonUpgradeWidget
      apiKey={apiKey}
      contractAddress={contractAddress}
      tokenId={tokenId}
      w3={web3}
      cb={(p) => console.log(p)}
      config={config}
    />
  )
}

export default Widget