Creating the smart contract

Before diving straight into creating the smart contract, let's define what we need it to do:

  • We need an array that will store each users' music recommendations in a string or bytes32 format
  • A struct to define user information
  • A mapping with each users' recommendations
  • An array of followed users so that we can see new musical updates

As usual, we start by creating the basic smart contract structure:

pragma solidity 0.5.0;contract SocialMusic {}

Then, we define the variables that we'll use, as follows:

pragma solidity 0.5.0;contract SocialMusic {    struct User {        bytes32 name;        uint256 age;        string state; // A short description of who they are or how they feel        string[] musicRecommendations;        address[] following;    } mapping(address ...

Get Mastering Ethereum now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.