Skip to content

Instantly share code, notes, and snippets.

@korrio
Created September 12, 2021 03:42
Show Gist options
  • Save korrio/ff39e4fab5fa1558587bd821b6862804 to your computer and use it in GitHub Desktop.
Save korrio/ff39e4fab5fa1558587bd821b6862804 to your computer and use it in GitHub Desktop.
MusicNFT.sol
pragma solidity ^0.6.12;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/token/ERC721/ERC721.sol";
contract InheritedToken is ERC20("Mocked DAI Token", "DAI-T") {
}
contract InheritedNFT is ERC721("KORRIO Collectiable", "KNFT") {
Music[] public musics;
address[] public tokenOwner;
constructor() public {
}
struct Music {
uint256 tokenId;
string title;
string album;
string artist;
string genre;
string artwork; // ipfs hash
string mp3; // ipfs hash
}
function mint(
string memory _title,
string memory _album,
string memory _artist,
string memory _genre,
string memory _artwork,
string memory _mp3) public payable {
uint256 _tokenId = totalSupply();
tokenOwner[_tokenId] = msg.sender;
// 1. memory-based
Music memory music = Music(_tokenId,_title,_album,_artist,_genre,_artwork,_mp3);
musics.push(music);
// 2. on-the-fly
// musics.push(Music({
// tokenId: _tokenId,
// title: _title,
// album: _album,
// artist: _artist,
// genre:_genre,
// artwork:_artwork,
// mp3:_mp3
// }));
super._mint(msg.sender, _tokenId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment