Use Openfort with Node.js
Learn how to get started with Openfort and mint an asset with NodeJS.
What you'll learn:#
- How to manage third-party dependencies using the npm or yarn package manager.
- How to install the latest Openfort Node SDK.
- How to send your first SDK request.
Set up a Openfort Node.js SDK
Open your project in the Openfort Dashboard.
The latest version of the Openfort Node.js server-side SDK supports Node.js versions 14+.
Prepare gas sponsorship
To offer gasless transaction (sponsor gas) in Openfort, your need to create a policy and a policy rule.
The policy rule will define the contract functions that you want to sponsor. In this example, we create a simple policy rule to pay for all user's interactions with the contract.
Mint an NFT
Now mint an NFT using the contract id and the player id that you created in the previous steps.
Openfort will encode the transaction based on the provided information in the interaction.
The smart account will be created and deployed automatically for you on the Mumbai network.
Because optimistic is set to
false, the response from creating the
transactionIntents will contain a
Remember to replace the policy, contract and player ids with your own.
Run the script
You're all set! Run the development server on your Terminal.
You can check the logs and events of the transaction intent in your dashboard.