Creating blockchain NFT-based customer experiences with Daml
Daml
Posted on April 21, 2022
The post was originally published on Daml Blog.
Blockchain non-fungible tokens (NFTs) have come a long way from their beginnings as proof-of-ownership of digital assets on the blockchain. As more and more creative digital assets are minted as NFTs on the blockchain using smart contracts, we have entered the next phase of evolution.
Now, the question many brands are asking is, How can we use blockchain NFTs to deliver differentiated experiences to customers who own our NFTs? This emerging trend of blockchain NFT experiences was also covered in a previous post: Top-five Enterprise Blockchain Priorities for 2022.
In this post, we will attempt to define an NFT blockchain platform, and discuss how to deliver blockchain NFT-based experiences. To illustrate this, we will be looking at Daml, a portable smart contracts language that allows for interoperability between public and enterprise blockchains, as well as traditional databases—whether on-cloud or on-premise.
Options for creating blockchain NFT experiences
Creating experiences based on NFTs can be accomplished in two ways:
By creating an NFT on a blockchain platform so that people can own it, and then by building a traditional software ecosystem around the NFT that checks ownership and provides various NFT experiences and privileges; or,
By making NFTs smarter, so that we can embed an extensible business logic directly into the NFT.
Using Daml, we’ll demonstrate how to create NFT-based experiences using the second option introduced above. The key benefit of option two here is that the entire process becomes much more transparent and accountable, as all of the actions can be tracked on the blockchain as smart contracts. We can still use the traditional format featuring a URL to a digital image along with transfer rights. Daml also allows the same blockchain NFT to reside on a permissioned enterprise blockchain, thus allowing brands tremendous flexibility in how they use the NFT to provide new experiences with this technology.
If you or your developer team haven’t yet installed Daml, you can install it here. Once installed, simply navigate to where you’d like to create the project, and create a new Daml smart contract project using the Daml assistant.
Creating our blockchain NFT-based experience
For our purposes, we will use the example of a rock band issuing an NFT that also serves as a ticket to their concert. We’ll then add additional programming (or rights and obligations) to the blockchain NFT so that new experiences can be created using the NFT in a transparent manner—directly on the blockchain.
In the new project we’ve created, we remove everything from main.daml except the line declaring the main modulem, and simply type in the following:
template RockBandNFT
with
uniqueNFTId: Text
imageUrl: Text
band : Party
fan : Party
-- benefits : Benefits
issuedDate: Date
where
signatory band, fan
This signifies a basic NFT contract. The Party datatype is what defines a unique party on the blockchain. The signatory keyword indicates that this token cannot be created without the consent of both the rock band and the fan. This is a unique advantage of Daml’s rights and obligations guarantee because it ensures that a token cannot be created without each of the signatories explicitly approving the transaction. These checks and balances are built into the platform, so developers don’t have to code any additional business logic. Since this smart contract has two signatories, it must be created only after approval from both parties. See this video on how to use this powerful feature of Daml.
Now that we have the core blockchain NFT or smart contract on the blockchain, we can start adding some rights and obligations to it. In our case, we’ll offer the fans an individually signed t-shirt (also an NFT) if they attend the next concert.
Now, let’s have the band create a new concert using the rights we have coded for them on the blockchain NFT. For that, Daml allows us to create a choice (a right) on the NFT smart contract. Here’s how that looks:
controller band can
CreateConcert: ContractId Concert
with
concertDate: Date
concertName: Text
do create Concert with ..
Note that only the band can create a concert—enforced here by the controller keyword. So if any party other than the band tries to create a contract, the execution will fail. This is another example of the Daml rights and obligations model available out of the box to developers.
The new concert looks like the following (as you can see, it also provides the customer a right to buy a ticket):
template Concert
with
concertDate: Date
concertName: Text
fan: Party
band: Party
where
signatory band
controller fan can
BuyConcertPass: ContractId ConcertPass
with
purchaseDate: Date
amount: Decimal
do
create ConcertPass with ..
As before, in our example, only the customer can buy a ticket—again enforced by the controller keyword in Daml. And when they do, they receive a concert pass. Since the concert pass is also a smart contract, once customers have a concert pass, then the band—also a controller on that smart contract—can now issue them a blockchain NFT for a T-shirt. The NFT for the T-shirt is, of course, also a smart contract allowing for future extensibility.
template ConcertPass
with
concertDate: Date
concertName: Text
purchaseDate: Date
amount: Decimal
fan: Party
band: Party
where
signatory fan
observer band
controller band can
IssueTShirtNFT: ContractId ConcertTShirtNFT
with
digitalURL: Text
do
create ConcertTShirtNFT with ..
template ConcertTShirtNFT
with
concertDate: Date
concertName: Text
digitalURL: Text
fan: Party
band: Party
where
signatory band, fan
The t-shirt NFT takes the URL for the digital image.
So, now we have two NFTs on the blockchain—one to represent the ticket and one to represent the t-shirt. What we can do to build on the NFT experiences is limited only by our imagination. For example, this t-shirt NFT can be redeemed or further gifted.
Why Daml for blockchain NFT experiences?
As of the writing of this blog, multiple layer one blockchains such as Solana, Avalanche, and Cardon have surfaced in addition to Ethereum, indicating a maturing of this space. So, when we create blockchain NFTs, we should keep portability of our smart contracts in mind; you shouldn’t have to tackle additional, complex technical initiatives in addition to running a blockchain NFT customer experience program. Second, the future of the DeFi and blockchain space hinges on interoperability. Daml allows blockchain NFT smart contracts to interoperate with each other when deployed on multiple blockchains. This is a huge advantage. Finally, Daml also runs on databases, so you could create an intra-enterprise NFT without having to work with a blockchain layer, all while keeping your smart contracts interoperable with an external blockchain network.
Finally, as you see in the code above, Daml focuses entirely on the business logic. All the underlying plumbing and idiosyncrasies of the underlying ledger platform are abstracted away and hidden from the developers, making for extremely rapid business deployment and validation.
The power of blockchain NFTs is beginning to emerge as a key tool for customer experiences. As ownership gives way to the need for providing experiences, it will be important to make the technical plumbing transparent to both users and developers in the enterprise. Interoperability and the flexibility of deploying NFTs on multiple blockchains is emerging as a critical success factor. Take a look at this article on tokenization and this one on asset tokenization that explore how blockchain NFTs will connect the world.
Damlprovides an excellent foundation from which brands can build on what they need to do to grow their eminence: Creating the immersive, NFT-based customer experiences of the future.
Posted on April 21, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.