- Primary Sales Contract: How to set up and deploy contracts for launching a primary sale — suitable for an Web Shop, NFT Drop, and more.
- Sequence Indexer: Leveraging the Sequence Indexer to query NFT metadata and user’s wallet assets.
1. Deploy your own Token- and Sale Contract in Sequence Builder
We first need a Primary Sales Contract along with an ERC1155 contract that will contain our game items we want to sell. To do that, please follow the guide here.2. Use the Primary Sales Demo inside Sequence’s Unity SDK
To get started, import Sequence’s Unity SDK into your project. Then, navigate to theDemo.unity
scene located Sequence Embedded Wallet SDK/Sequence/Samples/DemoScene
.
In this scene, you’ll find the PrimarySalePage
object, which serves as a useful reference.
3. Set your Sale Configurations in your Project
To configure your sale, use thePrimarySalePage
object to input your sale information.
In the Configuration section, you’ll find the following options:
- Chain: Select the chain where your contract is deployed.
- Token & Sale Contract Address: Enter the contract addresses provided by Sequence’s Builder.
- Items For Sale: List all the Token IDs you wish to sell.
4. Implement Custom Code to Interact with the SDK
Let’s create a custom class to manage the state for our sale. This class will gather all the necessary data, allowing us to display this information to users effectively. In the PrimarySalePage.cs demo, the data is sourced from the Configuration section.5. Retrieve Your Primary Sale Details
Next, use theERC1155Sale.cs
reference to obtain sale details and the payment token from the contract.
This information can be used, for instance, to locally verify if the user has sufficient balance for the specified payment token.
6. Fetching Token Metadata to Display Items to Users
We’ll use the Indexer API to retrieve token supplies for the specified token contract address. Be sure to use the address of the ERC1155 contract, not the sales contract.supply.tokenMetadata.image
variable from the token supplies mentioned above
to display your items to the user.
Ensure that you implement your own
AssetHandler
class to handle image downloads from remote URLs.7. Purchase an Item from the Store
This will call the mint function from the Sales Contract. By specifying the user’s wallet address as theto
parameter,
the contract will mint the item to that user. You can use the ERC1155Sale.cs
class to create a CallContractFunction
reference, which allows you to send a transaction to your sales contract using the user’s wallet.