Reader small image

You're reading from  Developing Blockchain Solutions in the Cloud

Product typeBook
Published inApr 2024
PublisherPackt
ISBN-139781837630172
Edition1st Edition
Right arrow
Authors (2):
Stefano Tempesta
Stefano Tempesta
author image
Stefano Tempesta

Stefano Tempesta is a technologist working at the crossroads of Web2 and Web3 to make the internet a more accessible, meaningful, and inclusive space. Stefano is an ambassador of the use of AI and blockchain technology for good purposes. A former advisor to the Department of Industry and Science, Australia, on the National Blockchain Roadmap, he is cofounder of Aetlas, a decentralized climate action and sustainability network with a mission to source verified carbon units for liquidity and carbon asset monetization. A passionate traveler, a poor musician, and an avid learner of new technologies and (programming) languages, Stefano holds three citizenships and speaks fluent English, Italian, and terrible Ukrainian.
Read more about Stefano Tempesta

Michael John Peña
Michael John Peña
author image
Michael John Peña

Michael John Peña, an engineer and Microsoft MVP, excels in tech innovation and leadership. As a data partner at Playtime Solutions, he spearheads projects utilizing Azure, big data, and AI, enhancing data-driven decision-making. With roles ranging from CTO to software engineer, MJ's expertise covers web/app development, cloud computing, blockchain, and IoT. His commitment to lifelong learning and sharing knowledge—underscored by his work with start-ups and as a technical advisor—drives industry advancements in finance, construction, and more. MJ values inclusivity and actively fosters diverse, collaborative environments.
Read more about Michael John Peña

View More author details
Right arrow

Creating Verifiable Digital Ownership on GCP

Digital ownership has become a cornerstone of our modern economy. As digital assets such as Non-Fungible Tokens (NFTs), cryptocurrencies, digital real estate, and intellectual property become more prevalent, verifying their ownership in a secure, transparent, and immutable manner has never been more critical.

The advent of digital ownership marks a paradigm shift in how we perceive and interact with assets in the digital realm, profoundly impacting various aspects of our lives. It empowers creators and consumers alike by providing a platform for authenticating, buying, selling, and trading digital goods with a level of security and transparency previously unattainable. This has opened up new avenues for artists, musicians, and writers to monetize their work directly and for collectors and investors to diversify their portfolios into digital art, virtual real estate, and other digital collectibles. Moreover, the use of blockchain technology...

Technical requirements

To run the scripts presented in this chapter, we need an account in GCP, which you can create for free, inclusive of $300 worth of credits, from here: https://cloud.google.com/

Code examples are provided in the Solidity and JavaScript programming languages. We will be using the following:

  • Remix (https://remix.ethereum.org/) for developing and testing the smart contracts
  • MetaMask or another Ethereum-compatible wallet for interacting with the Ethereum blockchain
  • Google Cloud’s Ethereum blockchain toolkit for deploying and managing the smart contracts

All the source code is available in the GitHub repository: https://github.com/PacktPublishing/Developing-Blockchain-Solutions-in-the-Cloud

Introduction to verifiable digital ownership

Verifiable digital ownership refers to a system where digital assets or rights are represented, tracked, and verified using blockchain technology. This concept is crucial in various applications, including cryptocurrencies, NFTs, digital rights management, and more. The key aspects of verifiable digital ownership include the following:

  • Digital assets on blockchain: Digital assets can be anything from digital art, music, videos, online collectibles, and virtual real estate to cryptocurrencies such as Bitcoin or Ether. These assets are often tokenized, which means they are represented as digital tokens on a blockchain. In the case of unique assets such as digital art, these tokens are often NFTs, meaning each token is unique and cannot be interchanged with another.
  • Ownership and provenance: The blockchain records who currently owns a digital asset. Each token has an owner, and this information is stored in a way that is transparent...

Setting up the blockchain network on GCP

One of the most important aspects of establishing verifiable digital ownership is the use of smart contracts. These contracts will encode the terms of the agreement directly written into code. In this lab, we’ll learn how to write and deploy smart contracts to manage and facilitate transactions related to digital ownership records. As consistently done in this book, we will work with the Ethereum platform and Solidity, the most widely used smart contract programming language for Ethereum and compatible blockchain networks.

As a hosting cloud of reference, for this lab, we’ll be using GCP. Before we start with Ethereum and GCP, let’s define a high-level plan of the tasks that we want to complete in this lab, as shown in the following figure:

Figure 15.1 – High-level tasks for the verifiable digital ownership solution on GCP

Figure 15.1 – High-level tasks for the verifiable digital ownership solution on GCP

We can detail the sequence of tasks as follows:

  1. Ethereum...

Creating verifiable digital ownership records

Once the hosting infrastructure is sorted, we can proceed with Step 2, which is building the smart contract that will do the following:

  • Register a new digital asset with unique attributes (for example, ID and ownership details)
  • Facilitate the transfer of ownership of a digital asset
  • Allow for the verification of the current owner of a digital asset

As mentioned in the technical requirements, we’ll be using the Remix IDE for coding the smart contract. Once the contract has been tested, we’ll deploy it onto the Ethereum testnet using Google Cloud’s Ethereum blockchain toolkit.

The contract exposes functions to add new assets, register a new owner, and transfer ownership. It will also verify the existence of the asset on the blockchain and its current ownership.

The smart contract that we’re going to develop is built on the ERC-721, NFT standard (https://eips.ethereum.org/EIPS/eip-721...

Integrating verifiable digital ownership with other GCP services

Managing digital assets in a decentralized manner generally involves storing data on the blockchain and providing functionalities to interact with that data. Blockchain’s immutable nature ensures the integrity and reliability of the data. In the context of Ethereum, this data management usually takes place within smart contracts, which may be complemented by decentralized storage solutions such as IPFS for handling large data or files. Let’s discover a few ways of storing and managing digital assets in a decentralized manner.

On-chain storage using smart contracts

In Ethereum, the most straightforward way to manage digital assets is by storing all necessary information within a smart contract. The following example extends the DigitalOwnership smart contract to include additional attributes, such as metadata, for each digital asset. Metadata can be in any form, for example, a JSON string or IPFS hash...

Deploying verifiable digital ownership on GCP

We’re at the final stage of our solution. Deploying a verifiable digital ownership solution on GCP involves several steps. This comprehensive guide outlines how to set up the required components, deploy the smart contract, and run the frontend application.

As we have already deployed the cloud infrastructure in a previous step, we now focus on the deployment of the smart contract:

  1. Compile the Solidity smart contract, if not already done, with the solc command:
    solc --bin --abi -o ./output/path/DigitalOwnership.sol
  2. Deploy the compiled contract using web3.js in a Node.js script (let’s call it deploy.js) to deploy the compiled contract. Make sure that the RPC port of the VM with the Ethereum node is accessible, or use an SSH tunnel to route the request:
    const Web3 = require('web3');
    const web3 = new Web3(new Web3.providers.HttpProvider("https://ethereum-node-address"));
    const abi = [...]; ...

Summary

In this hands-on lab, we explored the fundamentals of creating verifiable digital proofs of ownership of digital assets using blockchain technology on GCP. The lab is designed as an end-to-end tutorial, offering guided steps and code samples that cover key aspects such as Ethereum node setup, smart contract development, decentralized data management, and frontend application integration.

By completing this lab, we have gained a comprehensive understanding of how to build and deploy a complete blockchain-based solution for verifiable digital ownership. This knowledge is invaluable for anyone looking to implement secure, decentralized systems for asset management.

This chapter completes the three hands-on labs in the book. In the next and final chapter, we’ll draw some conclusions from this journey, and make some assumptions on the future of cloud-native blockchain solutions

Further reading

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Developing Blockchain Solutions in the Cloud
Published in: Apr 2024Publisher: PacktISBN-13: 9781837630172
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime

Authors (2)

author image
Stefano Tempesta

Stefano Tempesta is a technologist working at the crossroads of Web2 and Web3 to make the internet a more accessible, meaningful, and inclusive space. Stefano is an ambassador of the use of AI and blockchain technology for good purposes. A former advisor to the Department of Industry and Science, Australia, on the National Blockchain Roadmap, he is cofounder of Aetlas, a decentralized climate action and sustainability network with a mission to source verified carbon units for liquidity and carbon asset monetization. A passionate traveler, a poor musician, and an avid learner of new technologies and (programming) languages, Stefano holds three citizenships and speaks fluent English, Italian, and terrible Ukrainian.
Read more about Stefano Tempesta

author image
Michael John Peña

Michael John Peña, an engineer and Microsoft MVP, excels in tech innovation and leadership. As a data partner at Playtime Solutions, he spearheads projects utilizing Azure, big data, and AI, enhancing data-driven decision-making. With roles ranging from CTO to software engineer, MJ's expertise covers web/app development, cloud computing, blockchain, and IoT. His commitment to lifelong learning and sharing knowledge—underscored by his work with start-ups and as a technical advisor—drives industry advancements in finance, construction, and more. MJ values inclusivity and actively fosters diverse, collaborative environments.
Read more about Michael John Peña