Coding Journey: An Idea turned Obsession

Day 29


Began work on a Supply Chain Manager in Solidity on Remix to tract the purchase & delivery of an ‘Item’. The contract creates an item, triggers payment, & triggers a delivery in a function. So far its the most advanced contract I’ve worked on. This is from the Udemy: Ethereum Blockchain Developer Bootcamp with Solidity course I’m taking.

My organization is crazy I’m working on this main overarching tutorial to build my base while scraping the web for tutorials and resources to work on my own project. However, I have to remember, my goal was to learn Solidity in the first place. Thanks @abcoathup.

1 Like

If you are thinking supply chain, any thoughts to add on: Blockchain-based Life Cycle Inventory

1 Like

@abcoathup - I sent over a reply to the thread.

Day 30 & 31


Yesterday I finished my Supply Chain App, minus one bug in MetaMask that I will return to. Supply Chain is an interesting topic that I want to return to.


Today, I created an ERC20 token using OpenZeppelin and wrote the Unit Tests after deploying the contract to Ganache.

1 Like

Day 32


Wracking my brain trying to get this TokenURI JSON data to sync with OpenSea.

I successfully minted an NFT Token on the Rinkeby Blockchain and uploaded a NodeJS server to Heroku…(With a pause, a note to myself, that was a sentence I never thought would ever come out of my mouth). However, I had bug somewhere stopping OpenSea from seeing my JSON data. I have been at it since 7AM this morning and am taking a break. However, I won’t give up until I solve it and go Mainnet.

OpenSea Asset: https://rinkeby.opensea.io/assets/0x2c39cd072b3a125b4d29652560afc32e8f5f5ffc/0
NFT Image: https://gateway.pinata.cloud/ipfs/QmPYZ1gwj7P3VWK73RpHjgMNwj9CdymzocwitarHoAsqej
JSON: https://hashdeck2.herokuapp.com/api/token/1
Contract: https://rinkeby.etherscan.io/address/0x2c39cd072b3a125b4d29652560afc32e8f5f5ffc

1 Like

Hi @Proteu5,

I suggest verifying your token on Etherscan (so that people can easily call functions):

I used Remix to interact with your contract as an ERC721.

Your baseURI looks incorrect: https://hashdeck2.herokuapp.com/api/token/1

Which results in a tokenURI for tokenID 1 of: https://hashdeck2.herokuapp.com/api/token/11

If you have problems with OpenSea, you can ask in their Discord, they are super helpful: https://discord.com/invite/ga8EJbv

1 Like

Day32 & Day 33
You’re help @abcoathup allowed me to bring an ERC721 Mainnet Using the OpenZeppelin Preset! I ran into issues verifying the code and then I realized it would be much easier if I didn’t have to verify that entire preset.

Today I wrote a new ERC721 Solidity Contract from an older tutorial that I debugged to version 0.6.0 and adapted for the changes made to Open Zeppelin’s library.


I published my art to IPFS and uploaded the TokenURI NodeJs host to Heroku successfully. I then deployed the contract to Rinkeby and Minted the token to my address. It’s viewable on Rinkby.OpenSea!

I think this time I’m going to write some tests and verify the contract before going MainNet.
Thanks again for your help.

2 Likes

Hi @Proteu5,

Congratulations on deploying to mainnet! :partying_face: MAINNET!!

I want to create a tutorial for creating an art based ERC721 but haven’t come up with a simple way to create a JSON API. It would be great if you wanted to share what you did.

Feel free to ask all the questions that you need for verifying. The main issue I have found is ensuring you record what compiler version, optimization and EVM version was used to deploy the contract. A new issue is Solidity 0.6.8 introduces SPDX license identifiers and instead of flattening files, we will move to verifying multiple contract files.

I noticed in the screen shot of nft.sol that there isn’t any access control around mintUniqueTokenTo, so anyone can mint. I assume that is what you intended.

I am a big fan of auto token ID URI’s in the Preset to reduce gas cost. Though if you are including the IPFS hash in your tokenURI then this method isn’t for you.

I completely forget to add AccessControl to NFT.Sol and thank you for pointing that out to me. I will have to update my contract.

I will keep that in mind as I try and verify again after my changes. I may take you up on requesting for help as I keep getting errors.

For the JSON Api I followed the OpenSea MetaData Standards Documentation: https://docs.opensea.io/docs/metadata-standards and edited the NodeJs Server Example here following the GitHub Readme.md: https://github.com/ProjectOpenSea/metadata-api-nodejs

It was a sloppy edit but I needed something quick and dirty to get the Api Live. I edited the main body of index.js in the metadata-api-nodejs github

app.get('/api/token/:token_id', function(req, res) {
  const tokenId = parseInt(req.params.token_id).toString()
  const person = db[tokenId]
  const bdayParts = person.birthday.split(' ')
  const day = parseInt(bdayParts[1])
  const month = parseInt(bdayParts[0])
  const data = {
    'name': 'Castle Rays',
    'description': 'Bath, England - By: Proteu5.Art',
    'image': `https://gateway.pinata.cloud/ipfs/QmdeyMmvrP9dfoimozomsewLtDvSevep6czviirmXMXkbX`
  }

Removing all of the variables nullified the code I left in so that the output is as follows when hosted live:
{"name":"Castle Rays","description":"Bath, England - By: Proteu5.Art","image":"https://gateway.pinata.cloud/ipfs/QmdeyMmvrP9dfoimozomsewLtDvSevep6czviirmXMXkbX"}

Again, it was sloppy, but got the job done. I couldn’t find a good tutorial on hosting ERC721 Api data. I used Heroku to host the data.

Edit:
I cleaned up the NodeJS Api Example. All you have to do is edit constants.js with your base Heroku API and edit the metadata after deleting/commenting out the following:

const express = require('express')
const path = require('path')
const moment = require('moment')
const { HOST } = require('./src/constants')
const db = require('./src/database')

const PORT = process.env.PORT || 5000

const app = express()
  .set('port', PORT)
  .set('views', path.join(__dirname, 'views'))
  .set('view engine', 'ejs')

// Static public files
app.use(express.static(path.join(__dirname, 'public')))

app.get('/', function(req, res) {
  res.send('Get ready for OpenSea!');
})

app.get('/api/token/:token_id', function(req, res) {
  const tokenId = parseInt(req.params.token_id).toString()
  //const person = db[tokenId]
  //const bdayParts = person.birthday.split(' ')
  //const day = parseInt(bdayParts[1])
  //const month = parseInt(bdayParts[0])
  const data = {
    'name': 'Castle Rays',
    'description': 'Bath, England - By: Proteu5.Art',
    'image': `https://gateway.pinata.cloud/ipfs/QmdeyMmvrP9dfoimozomsewLtDvSevep6czviirmXMXkbX`
  }
  res.send(data)
})

app.listen(app.get('port'), function() {
  console.log('Node app is running on port', app.get('port'));
})

// returns the zodiac sign according to day and month ( https://coursesweb.net/javascript/zodiac-signs_cs )
//function zodiac(day, month) {
//  var zodiac =['', 'Capricorn', 'Aquarius', 'Pisces', 'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio', 'Sagittarius', 'Capricorn'];
//  var last_day =['', 19, 18, 20, 20, 21, 21, 22, 22, 21, 22, 21, 20, 19];
//  return (day > last_day[month]) ? zodiac[month*1 + 1] : zodiac[month];
//}

//function monthName(month) {
//  const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
//  ]
//  return monthNames[month - 1]
//}

An ERC721 Token Tutorial for Art would be awesome!

1 Like

Adding a test for a revert when an account without the minter role trying to mint is great at picking this up.

My quick and dirty effort was to manually generate the JSON and put them on GitHub pages.

It's on my todo list. Still thinking of how to do the API. Heroku might be best.

1 Like

Day34


I made some changes to include access control for my ERC721 contract. I still need to write tests to see if I did it correctly.

@abcoathup I’m not sure how I could help but if you need anything please let me know. I’d be glad to be of service.

1 Like

Hi @Proteu5,

I have drafted a tutorial that is still very much a work in progress for creating an NFT: [DRAFT] Create an NFT and deploy to a public testnet, using Truffle. Feedback is appreciated. I will do some more work on this next week. It doesn’t have any tests, so I may go and add some basic ones.

1 Like

Day 34


I did some jumping around and had to finish my ERC20 Crowdsale ICO with KYC from a tutorial I was taking. I finished it successfully and took it to testnet without any issues. I then added a Staking feature to the token. Only one of my tests are failing now. I published the code on GitHub: https://github.com/n0rthbridge/Crowdsale-ICO - I now have to finish the revert tests for my ERC721. It was a small jump in projects but this was on my mind.

@abcoathup - I will take your tutorial later tonight, lastest tomorrow morning when I wake up and give feedback! I’m exicted to follow it.

Day35
Followed @abcoathup 's Guide on Minting an NFT

Rinkeby Asset Validated:
https://rinkeby-api.opensea.io/asset/0x9b55fa972eeBB1b4110AE0bdDda34d49794EeEb7/0/validate/

NFT on OpenSea:

Feedback on Tutorial:
It was beautiful and easy to follow. I loved it. It took a little to figure out how to host the JSON Data via Github, the instructions weren't so clear on the website you linked to and I had to do some digging on how you hosted your code but I figured it out. I know your tutorial isn't finished but it made several assumptions:

Knowing to run "npm install @truffle/HDWallet-Provider" a super beginner may be lost without the 'npm install' part but also I knew to add this to my truffle config file:

const { projectId } = require('./secrets.json');
const HDWalletProvider = require('@truffle/hdwallet-provider');

I also had a structured secrets.json file

{
"projectId" : "infuraKey"
}

I actually ran into an issue, my mistake, I forgot the trailing forward-slash on the TokenURI so it looked like:

https://my-json-server.typicode.com/n0rthbridge/json-db/tokens0

vs

https://my-json-server.typicode.com/n0rthbridge/json-db/tokens/0

Then again, these assumptions were fine for the skill level I am at and someone should know these things so I can see why you left them out. Installing an NPM package, setting the 'const', and creating the secrets file are accepted knowledge.

I would love to have tests too, I can't wait for you to finish the tutorial. It was a pleasure to follow, simple, and exactly what I needed. You did a perfect job. You shaved over an hour of work off of my method of using Heroku by using Github, thank you for sharing that, that made my day.

2 Likes

Hi @Proteu5,

Thank you for going through the tutorial. I'm glad you could create an NFT on a testnet after following it.

I had hoped that people could use Connecting to Public Test Networks with Truffle but it sounds like I should copy some more key points from that tutorial to make it easier.

I think the formatting of the URI is going to be problematic so definitely worth adding a test for.

Awesome to hear. I need to add more about the JSON hosting, as this is just for Beta. For production need to host somewhere with higher guarantees on availability.

My thought here is that projects should get a domain name and use that in their baseURI so then they can change where the domain name points to rather than having to change the URI. This would allow starting with something basic, with the option to move to somewhere with higher availability.

1 Like

Day 36 & Day 37
It’s been a little bit since I’ve posted. I brushed up on some basics with CryptoZombies again from the start. Next, I polished some code for an ICO utility token and began extensive research regarding SEC Regulations in the USA. I found a KYC platform as well that is reasonably priced. I also planned and plotted out what is needed to do an ICO in the US. I think the solidity part was the easy part haha. Things sure have changed.

@abcoathup I’m excited for the final tutorial. All of the regulations surrounding ICOs and ERC20s is discouraging but ERC721 and being able to take them to mainnet are a breath of fresh air.

1 Like

Hi @Proteu5,

For fungible tokens, the challenges are in the regulatory compliance, the security and the tokenomics. I have a wiki post on Points to consider when creating a fungible token (ERC20, ERC777). Feel free to add/update the post based.

I think the interesting (and fun) areas of experimentation are personal fungible tokens and NFTs.

1 Like

Since my last post I’ve been working on one of my ERC20 Crowdsale ICO contracts. I’ve upgraded the contract to ERC1404 from solidity 0.4.2. I learned about breaking changes in solidity 0.6.0 with .length being read only and the use of .pop().

I was able to verify one of my contract version and I’m looking to verify a new version of the token tonight.

Edits:

Verified Token: https://rinkeby.etherscan.io/token/0xabda077d2c2ed6b751ea7d640da7d764d43ff5a7#writeContract

Verified Crowdsale:

That list is really useful and made me think long and hard about the Token. I’m still developing it, but thank you.

1 Like