Use Openfort with CSharp
Learn how to get started with Openfort and mint an asset with CSharp.
What you'll learn:#
- How to manage third-party dependencies using the .NET Core CLI, NuGet CLI or the Package Manager Console
- How to install the latest Openfort CSharp SDK.
- How to send your first SDK request.
Set up a Openfort CSharp SDK
Open your project in the Openfort Dashboard.
After your project is ready, grab your secret_key and public_key from the project.
Add a contract to Openfort
In this tutorial, we'll use a simple ERC-721 contract on the Amoy network deployed at 0x380...AC0.
Once added, Openfort will return a contract id that you can use to interact with the contract. It starts with con_
.
Prepare gas sponsorship
First, we'll create a policy to sponsor the gas fees for the contract.
Thebn, we'll create a policy rule to define the contract functions we want to sponsor. In this example, we create a simple policy rule to pay for all user's interactions with the contract.
Grab your contract id and the policy id to include on your call.
Mint an NFT
You're all set! Now you can mint an NFT using the contract id and the policy id that you created in the previous steps.
Openfort will encode the transaction based on the provided information in the interaction.
An account will be created and deployed automatically for you on the Amoy network.
Because optimistic is set to false
, the response from creating the transactionIntents
will contain a response
.
Go ahead and replace the code in Program.cs
with the following code.
Remember to replace the policy, contract and player ids with your own.
Run the script
Run the program.