# 🔮 Alchemy University: Ethereum Developer Bootcamp - Day 1 - The First Primitive

By [alp1n3.eth](https://paragraph.com/@alp1n3.eth) · 2024-06-21

---

⚠ These notes do not cover all topics discussed, they will mainly be looking just at things I thought I’d need to cover deeper ⚠

💬 Joining the Discord & a Guild
================================

I had some initial issues joining the Discord due to permission issues, and it turned out to be that my Arc Browser had gotten something screwed up and wasn’t launching Discord correctly. I ended up just using Firefox to complete the account connection process with Alchemy, but a wipe of the cache on Arc might also be able to solve the problem.

It looks like there is a ton of great content and super cool people on the Discord, so I’m really looking forward to interacting with everyone and learning from them. I went ahead and joined the “Developer Guild” as a “Developer Apprentice”. If you see me hanging around don’t be afraid to say hi!

🟩 What is the Purpose of a Blockchain?
=======================================

> Plain and simple. _Any_ person or organization should be able to _participate_ in this process. _No_ person or organization should be able to _control_ this process.

This is an important note that deeply resonates with the crypto community in general. I feel like less people “see” the traditional borders of nations and states as a necessary item when participating in the global economy, and crypto helps push the individuals utilizing it into being more of a “global citizen” or “digital citizen”. The protocols are open, the tokens are easily flowing, all you have to do is participate. Instead of a 2 week settlement time and $20 in fees someone could have sent their grandma in the EU $500 to help with rent, or it could be there in under a minute using USDC. Of course, there are many upsides and downsides that come with these options, but I thought it was an interesting start to the course to reinforce those kind of underlying values.

🪟 Trust, Transparency, and Labor
=================================

With a traditional banking setup you are placing your blind trust in the bank to keep your money safe, along with the government to ensure that it will back you up if your bank goes under. Alongside that, there is generally no transparency available to the average consumer in this operation, as the bank and the software it runs on is not anywhere near being what could be described in typical web2 standards as “open source”. The labor involved at the bank impacts not only the trust, but the availability of the bank. What happens if the only two tellers are out sick? What happens if the bank manager gets hit by a bus in the morning? That’s automatic downtime for the bank and a restriction of your physical access to your own money through that branch.

These are all worst case scenarios of course and banks are required to maintain certain branch-wide uptime numbers in order to continue operating, but scaling it down can really show how easy it would be for this system to spiral out of control or for something to happen at any point of the normal banking process. In general, there is no way for the average consumer in a banking operation is able to verify right then and there that:

*   The teller won’t steal the money.
    
*   That the balance in their account is actually there and accessible.
    
*   That their transaction will go through within 30 minutes.
    
*   That the software or banking platform is secure or has been audited.
    
*   And a myriad of other things.
    

It’s just so closed source and centralized, it’s almost anti-consumer. So where does “trustless” come in?

> To tie it altogether, blockchain was invented to solve for **trust**. To create a system that is completely neutral and resistant to any censorship or bribe.

🧠 Smart Contract Blockchains
=============================

Smart contracts brought blockchains to the next level by enabling code to be run everywhere (decentralized), making that code essentially a public resource. No one owns the code, it exists on the blockchain, and it is able to be seen and evaluated by everyone. When that code is deployed to the blockchain, magical things happen.

> nodes in the network will enforce the logic of the code through the financial incentives of the blockchain protocol.

#⃣ Cryptographic Hash Functions
===============================

Hashes need to be:

*   Deterministic
    
*   Pseudorandom
    
*   One-way
    
*   Fast to Compute
    
*   Collision Resistant
    

An easy way to take a quick look at what a SHA256 hash is to open your terminal window and type the following command, and then append a random file to the end of it. The output is the hash of the file.

    openssl sha256 <test file here.txt> SHA2-256(<test file here.txt>)= 1108cc5f0348120e744e6e8a17aba4a99bce53eefd96e94aa3c361e9f688885d

I’ve played around with hashing quite a bit in the past so I’ll just leave a handy tool [here](https://gchq.github.io/CyberChef/). The entirety of crypto relies on cryptography… without it, we wouldn’t have any of this.

🎨 Find Favorite Color
======================

Solution:

    const { sha256 } = require("ethereum-cryptography/sha256"); const { toHex, utf8ToBytes } = require("ethereum-cryptography/utils"); // the possible colors that the hash could represent const COLORS = ['red', 'green', 'blue', 'yellow', 'pink', 'orange']; // given a hash, return the color that created the hash function findColor(hash) { return COLORS.find(x => toHex(sha256(utf8ToBytes(x))) === toHex(hash)); } module.exports = findColor;

Constant “COLORS” contains an array of strings that have the colors that need to be hashed and compared. “.find” is [described as](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find):

> The `find()` method of `Array` instances returns the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, `undefined` is returned.

This means that the “x” within it is each string within the array that is then passed to the comparison functionality after the string has been converted from UTF8 to bytes, hashed, then converted to hex. After all of that, it is compared to the original hash that is passed to the “findColor” function, which is called by “test.js” where it loops through the array of the colors.

Going through this exercise has made me realize it has been a hot minute since I’ve actually written anything in JavaScript though, so I may pause this course and go run through Alchemy’s other course; [Learn JavaScript](https://university.alchemy.com/overview/js).

---

*Originally published on [alp1n3.eth](https://paragraph.com/@alp1n3.eth/🔮-alchemy-university-ethereum-developer-bootcamp-day-1-the-first-primitive)*
