unity-example
Setup a Unity demonstration utilizing Crossmint in just a few minutes!
This example showcases Crossmint's Custodial Wallets and Minting ability.
This isn't a game but rather just a simple menu to demonstrate the ability you have using Crossmint in your own personal game/project.
1. Grab your Crossmint keys
We have two environments, one for testing and one for release. These environments are selected based on the subdomain you select. staging.crossmint.com
is the testing environment and www.crossmint.com
is the release environment. Throughout this tutorial, we will be using the staging subdomain (testing environment). These steps are identical for either environments with the only difference being the domain you're using.
In the Crossmint console
-
Go to staging.crossmint.com/console and follow the steps to create an account.
-
Navigate to API keys and click on New API Key. Then check the
nfts.mint
,wallets.read
,wallets.create
andwallets:nfts.read
scopes -- this will give your API key permission to create and manage crypto wallets and mint for your users. Finally save your new key and copy theCLIENT SECRET
andProject ID
values for later.
On your machine
Open the BackendServer
project, rename the .env.template
file to .env
.
In the .env
file, fill in the fields with your information gathered from the Crossmint console (CROSSMINT_X_CLIENT_SECRET
and CROSSMINT_X_PROJECT_ID
).
The result should look something like this:
CROSSMINT_BASEURL=https://staging.crossmint.com
CROSSMINT_X_CLIENT_SECRET=YOUR_CROSSMINT_CLIENT_SECRET_HERE
CROSSMINT_X_PROJECT_ID=YOUR_CROSSMINT_PROJECT_ID_HERE
CROSSMINT_CHAIN="polygon"
CROSSMINT_COLLECTION_ID="default-polygon"
PORT=3000
You can now modify the chain, collection and port to your desired values.
And then save.
Please note: make sure the client secret doesn't get leaked, as it would allow others to create wallets for your users.
2. Configure the BackendServer project
-
Open
index.js
and configure the project based on the instructions presented in the authentication method on line 9. -
Start the server by running the following command in the
BackendServer
directory:
node index.js
3. Configure Unity
-
Open the project in Unity Editor (the project was created on 2021.3.21f1)
-
Open the C# project (Assets -> Open C# Project)
-
Open
Config.cs
and update theBackendServer
url. -
Ensure the
BackendServer
is running and start the game!