Cryptocurrency Transactions on a Public Ledger

This is module 3 of 10 for the Blockchain and Cryptocurrency course.

Module 2 << | >> Module 4

Readings

Cryptocurrency Transaction

Ledger

Public Blockchains

+

Self-Directed Learning

  • Send crypto to someone in the class or to a friend. Cryptocurrency was created as a peer-to-peer system for transferring funds. This will involve one person sharing their blockchain address with another. If you don’t know anyone, a last resort is to create a second address (account) under your wallet and send crypto from one of your accounts to another. Avalanche is a good blockchain network for speed and low fees, so sending AVAX on Avalanche is a good place to start. (Feel free to ask your friend to send the crypto back.)
  • Before you click “Confirm” for the transaction, open a timer on your phone and time the lag from clicking confirm to the transaction being confirmed. Your wallet will show the transaction as pending until it is confirmed.
  • Most blockchain explorers report dollar equivalents next to crypto amounts. Click on your transaction and view it on a block explorer. You can see the amount you sent in dollar terms, the transaction fee amount in dollar terms, and you can calculate the transaction fee in percentage terms.

+

Online Discussion of Module Topic

Write down what you are learning and questions that you may already have. Here are some prompts to get you thinking:

  • Hopefully you were able to measure the amount of time it took for the transaction to be confirmed. What was this amount of time? Does this seem fast or slow to you? How does it compare to a card transaction?
  • With a blockchain explorer, you can observe the amount sent and the fee. Share this information — amount in dollar terms, fee in dollar terms, and fee in percentage terms. How do you feel about the transaction fee? Does it seem high or low to you? How does it compare to a card transaction?
  • How did your experience of transferring funds to a peer compare to using Venmo, Zelle, What’s App or some other app for sending money? Do you think digital wallets could compete with these existing apps? What are the hurdles to adoption?

+

Technical Exercise

The technical exercise for Module 3 is to complete the Sending Transactions Using Web3 tutorial you started in Module 2.  

Step 1. Read the full “Steps to Sending Your Transaction” section on the ethereum.org article Sending Transactions using Web3. You completed the first two steps of this section in Module 2.

Step 2. Work through steps 3 through 5 in the “Steps to Sending Your Transaction” section. You will first be creating a directory (folder) for a local project. You can create this directory in the same folder where you are doing your GitHub assignments. Step 3 of the tutorial is simply using the command line interface (which is the Terminal for Mac or GitBash for Windows) to make this directory (mkdir) and then move into it (cd is change directory). In Steps 4 and 5 of the tutorial, you are installing the Alchemy Web3 dependency and dotenv (for private key management) from npm. Do you remember installing npm on your computer in module 1? This is why! As a reminder, npm is the world’s largest public database of JavaScript packages (software). When you install the packages from npm, you may get some warnings about deprecation. That’s OK. You do not need to run any other commands.

Step 3. For Step 6 of the tutorial, you are going to create a .env file. You want to create this in your sendtx-example directory. To create this file, open your code editor, like Visual Studio Code, and create a new file named .env to begin. Once you’ve created the file, simply copy and paste the two lines of code from the tutorial. Now you are going to update the code with your personal Alchemy/Metamask information. The next step is to go to alchemy.com and login to your account. Remember creating an “app” in Module 2? Once on alchemy, follow the tutorial instructions for copying the url for your app and pasting into “your-api-url”. Next, follow the tutorial instructions for exporting a private key from Metamask. Make sure that you are in your account with the GoerliETH and export the private key for that account. It will be a string of letters and numbers that you copy and paste into “your-private-key” in the .env file. Note the warning to never share this information!

Step 4. In Step 7 of the tutorial, you will now create your first ever Javascript file called sendTx.js to be able to programmatically send an Ethereum transaction. You are going to send your test ETH to a different address. To create the sendTx.js file, simply start a new file in your code editor (like Visual Studio Code) and copy and paste in the code from the tutorial. Make sure to save the file in your sendtx-example directory. Once you have the code in your editor, the next step is to replace the public address in line 6 with your public address. To do this, simply go to your Metamask wallet and copy the address for your account with the GoerliETH, just like you would to receive funds from a friend using a public address for a peer-to-peer transaction. Except you are doing this to send the transaction. Before proceeding to step 8 of the tutorial, make sure to complete the following.

Step 5. We need to make a few more changes to the “Transaction” object in the code before running it in Step 8 of the tutorial. First, the default code sends the test ETH back to the faucet. Rather than doing this, we are all going to send our test ETH into an address managed by Professor Black so that we can see all the transactions in one place. To make this change, replace the ‘to’ address on line 11 of the code with the address provided in the D2L discussion topic instructions. Next, the Goerli faucet only funded us with 0.2 GoerliETH. So we need to reduce the size of the ‘value’ of the transaction in line 12 of the code. The default value is 1 ETH, which is written as 10^18 Wei. If you delete two zeroes, this will reduce the value to 0.01 ETH. You should send this amount or some amount around that size. To do this, simply edit the number in the value field of the code.

Step 6. Run the code following the instructions in Step 8 of the tutorial. If it was successful, you just wrote your first transaction to a blockchain! Congrats!!

Step 7. View your transaction in the Mempool (Step 9 of the tutorial). Take a screenshot of the successful transaction on the Alchemy page. It should look similar to the screenshot in the tutorial.