Skip to main content
Version: V2

Set Essence Middleware

Workflow

Set middleware for essence is a powerful API that allows developers to customize their apps and create a unique experience for their users. The API interacts with the smart contract and sets the defined rules on how it should behave for a specific action, such as collecting an essence.

  1. First, data should be presented to the user in a readable format when signing from the wallet. To do that you’ll need to call the createSetEssenceDataTypedData API that takes care of this.

    If you’re unfamiliar with typed data, you can read more about it here.

    This API sets/updates the parameters for the essence such as tokenURI and middleware so when a user collects this essence, the Middleware will be triggered and the NFT minted will have the specified Token URI.

    In this example we are setting the collectPaid middleware which will require the user to pay a fee to collect the essence.
    To view a full list of supported middlewares check out the Middleware guide.

caution

This API requires Authorization header with the Bearer token. You can learn more about it here.

  1. Second, once you received data in a readable format, you’ll need to get the user’s signature for it. Basically, you’ll need to write a function and pass it a message as a param and return the signature that it’s necessary for the next step.

  2. Third, you’ll have to call the relay API that will broadcast the transaction and interact with the smart contract setting the middleware, you will need to put as params the typedDataID you received from createSetEssenceDataTypedData mutation call and the user's signature.

caution

This API requires Authorization header with the Bearer token. You can learn more about it here.

You can now verify the transaction by looking up the txHash from the response on etherscan.io. That’s it! You’re all done!

Experiment in Sandbox

We’ve created an example that incorporates all the steps for Set Middleware for Subscribe. Feel free to experiment with our code in the sandbox below.

Designed by