How to use the Mintplex embed with custom buttons

Sometimes the default styling for our button is insufficient for the theme or layout of your minting site.

circle-exclamation

When you should be doing this...

  • You have a website with a specific theme or layout in which our default button is inadequate.

  • You use a JS-rendered (React, Vue, etc) site where the implementation of an HTML snippet is not easy to include.

  • You want complete control of the style and layout of the button, but do not have to worry about all the complex contract logic associated with minting.

Implementation

In general you would take your HTML snippet from your Mintplex project page and then add a new data-attribute to the HTML like so...

<!-- Minting button provided by Mintplex.xyz -->
    <div id='rampp-minting-container-1461b754-eeb4-47f4-8cef-02262623c9ea' class='rampp-minting-container'>
      <button 
        id='rampp-minting-button-1461b754-eeb4-47f4-8cef-02262623c9ea' 
        class='rampp-minting-button'
        ...
        data-custom-mode="true"  <-- Add this!!! -->
      ></button>
    </div>
    <!-- 
      Don't forget all the default scripts that are imported in the normal Embed.
      Especially don't forget the Mintplex/embed script!
    -->
    <script type='text/javascript' src="https://mintplex.xyz/embeds/v2.1/embed.js"
      data-uuid='1461b754-eeb4-47f4-8cef-02262623c9ea'></script>
<!-- End Mintplex.xyz minting button-->

Importing the above anywhere in the component/page will have the mintplex button code load but with data-custom-mode=true the button will not render but all logic is available.

To invoke a simple call window.executeMint(qty); to start the minting process.

HTML

Working Example: https://replit.com/@timothycarambat/RamppCustomInvoke#index.htmlarrow-up-right

Here we have a regular HTML button as so

With a supporting minting action that is written as so:

React.js

With React or other JS-rendering frameworks, you will need to be more proficient with your framework of choice as we do not provide a default library or NPM package to support this flow - that being said implementation can be trivial.

Working Example: https://replit.com/@timothycarambat/ReactJS-with-Custom-Mode-Mintplex-Embedarrow-up-right

Here we again have a custom button component

We also abstract out the creation and embedding of the HTML component into a React hook. There are other ways to do this of course, but this is just an example of how to do it.

That's all!

Of course, you should always test your button on the testnet contract to ensure it works, and then when on mainnet copy the new data-attributes to the existing integration in your code, and all should work! If clicking the button opens MetaMask - you are done!

Last updated