My Coding Journey: Beginner to Pro

A friend in my Slack group inspired me to start recording my coding journey. I’ve already been learning to code on the blockchain for a few months though. So while this is Day 1, it’s technically Day1 += 4mos;

Day 1:

Building a token contract from scratch & first steps to build a separate token contract using the OpenZeppelin library.


10 Likes

Day 2:
-Completed chapter 2 and began chapter 3 of CryptoZombies.

-Explored the trufflesuite packages library for standard project dependencies.

-Completed initial set up for a token sale project.

Crowd sale smart contract begins tomorrow!

2 Likes

Day 3:

-Began crowdsale contract construction and initial unit testing.

-Encountered error in finding the bignumber.js file that accompanies chai. (Updated NODE_PATH environment variable with no luck.)

-Nearly finished chapter 3 of CryptoZombies.

2 Likes

Day 4:

-Truffle v5.x uses bn.js instead of bignumber.js, so it requires chai-bn instead of chai-bignumber. Issue resolved!

-Also, bignumber > toNumber() because of Number.MAX_SAFE_INTEGER

-Found helpful usage notes for chai-bn in the OpenZeppelin repository. Thanks guys!

4 Likes

Day 5:

-Completed Lesson 3 in CryptoZombies & starting Lesson 4.

-Made token and crowdsale mintable by importing the MintableCrowdsale.sol and ERC20Mintable.sol contracts.

-Created a helpers file for to wei conversions, but have a new error: web3.BigNumber is not a constructor

Any feedback is greatly appreciated!

error_D5

5 Likes

Hi @Jshanks21,

Thank you so much for sharing your journey. Loving reading your progress so far.

I suggest using OpenZeppelin Test Helpers for big number support. Performing Complex Assertions has an example of how to use (this is with OpenZeppelin Test Environment but can be used with Truffle too). The OpenZeppelin Contracts tests are also worth looking at.

I really like OpenZeppelin CLI for the interactive commands and now with OpenZeppelin CLI 2.8: Release Candidate it supports regular deploys.

Feel free to ask all the questions that you need, and please keep sharing your journey, it is great to follow.

2 Likes

Thank you @abcoathup! I’ll be sure to check that out today.

1 Like

Day 6:

-Error resolved! Using web3.utils.toBN in helpers instead of web3.utils.BigNumber b/c Truffle v5 supports BN not bignumber.

-Added some initial minting tests.

-All current tests pass!

-CryptoZombies Lesson 4 @ 38%

// TODO: Read through some OpenZeppelin tests contracts, check out Ethernaut, and migrate tests from Truffle to try the OpenZeppelin testing library.

Feedback is always appreciated!

Resolved_D6

preAddMinter_D6

passedTests_D6

1 Like

Thanks for sharing this awesome series with the community


I would try the Solidity 0.5 version of Ethernaut (https://solidity-05.ethernaut.openzeppelin.com/) (Once OpenZeppelin Contracts 3.0 is out of beta can see who in the community wants to upgrade the contracts to Solidity 0.6).

There are a number of community solutions, though it would be great if you wanted to write your own as well: Ethernaut Community Solutions


It is fairly straight forward to migrate from Truffle tests to OpenZeppelin Test Environment (and vice a versa if using mocha/chai based tests). I used this guide: https://docs.openzeppelin.com/test-environment/0.1/migrating-from-truffle
Feedback on the documentation is greatly appreciated.

1 Like

Sweet! Thank you for the resources. I’ll be sure to check them out.

1 Like

Day 7:

-Added the OpenZeppelin test library to my tests
+Kept getting an error about the timeout exceeding 2000ms, so I added a quick fix that disables the timeout this.timeout(0);, but maybe there’s a better fix for this? Perhaps a configuration I overlooked?

-Completed Lesson 4 of CryptoZombies

-Refresher on the batchOverflow hack on BEC

-Studied the MakerDAO vulnerability in the DSChiefApprovals contract, extended by the DSChief contract, identified by OpenZeppelin

testsPass_D7

1 Like

A post was split to a new topic: Timeout exceeding 2000ms

Day 8:

-Imported CappedCrowdsale functionality.

-Added some natspec descriptions.

-Added testing for capped crowdsale functionality. All tests pass! (So far.)

-Completed lesson 5 in CryptoZombies.

cappedTestPass_D8

1 Like

Hi @Jshanks21,

Thanks for sharing as always. :pray:

Just as an FYI: Crowdsales are not included in the OpenZeppelin Contracts v3.0 beta release and there are no plans to migrate them to Solidity 0.6.

Crowdsales were removed: we’ll continue to provide support for security issues on the v2.5 release, but will not bring them over to v3.0.

No worries! Happy to share.

I know they won’t be included in v3.0. However, I never learned how to develop them when they were popular. And in case Hester Pierce passes that bill giving ICOs a 3 year grace period, it could be helpful to know. :partying_face:

Regardless, this is all educational. I don’t intend to implement this project for production.

1 Like

On the note of education about crowdsales, it would be worth having a look at TokenTimelock and TokenVesting

I wrote an example recently:

2 Likes

Perfect timing! I planned to add some timelock features next. Thank you!

1 Like

Day 9:

-Imported TimedCrowdsale.sol and added constructor arguments for them. I also added some tests, but ran into issues seen below. I believe the issue has to do with the JavaScript integer limitation MAX_SAFE_INTEGER. However, I still had issues when trying to wrap the integers in a string or BN though. The specific line of code that seems to cause this error is highlighted below.

-Finished reading about the critical vulnerability in MakerDAO and started reading the initial audit for Compund.

-Reached level 2 in Ethernaut!

timedTests_D9

The line below seems to cause the error. When commented, the tests complete with the given opening and closing times. Of course, they don’t all pass without the line below though.
timeIncreaseError_D9

1 Like

Hi @Jshanks21,

Would you mind posting the failing test and contract in the forum and I can try to reproduce?

A post was split to a new topic: Number can only safely store up to 53 bits