Skip to content

ffrancis-reis/ethereum-developer

Repository files navigation

Ethereum Development Basics

Introduction

A simple blockchain project to show the basics of smart contracts and Ethereum development. The Album.sol is a simple smart contract that demonstrate a descentralized, permanent ledger to keep track of albums that any device would play and therefore being a trusted source that allow calculation of royalty payments.

Important: The project was made with the versions below, but the contracts use different versions of the Solidity compiler. I suggest compiling and deploying the contracts in Remix IDE.

  • Truffle v5.4.7 (core: 5.4.7)
  • Solidity v0.7.0 (solc-js)
  • Node v16.13.0
  • Web3.js v1.6.1

Important: The project didn't use any external libraries worth mentioning and also didn't use IPFS to host the frontend part decentralized as well.

Getting Started

  1. Clone this repository.
  2. Take a look at the smart contracts made at Remix, a browser-based IDE to develop Ethereum smart contracts. Ethereum is a decentralized platform that runs smart contracts.
  3. Install the dependencies with NodeJS and NPM.
  4. Test the application by updating the album details.
  5. You can also test in Remix IDE after deploying to a test network like Rinkeby Test Network and look at the transactions happening on it.

Dependencies

  1. Create an account and install the Metamask extension on your web browser. Also claim some ethers (ETH) from a Faucet to use for testing purposes.
  2. Create an Infura account to publish the contracts into the Rinkeby Test Network.
  3. Install Truffle CLI. Truffle is the most popular development framework for Ethereum.
  4. Install Ganache. Ganache is part of the Truffle suite that you can use to run a personal Ethereum blockchain.

Important: You will need your personal passphrase from your Ethereum account to publish into the Rinkeby Test Network.

Instructions

  1. By testing the Album.sol smart contract on Remix you can compile and deploy it:

image

image

image

  1. After configuring your Metamask and Infura account, and getting some ether, you can see your balance by running the commands below:
  let infuraProjectId = '6e...'
  let metamaskWallet = '0x...'
  let Web3 = require('web3')
  let web3 = new Web3(new Web3.providers.HttpProvider('https://rinkeby.infura.io/v3/' + infuraProjectId))
  web3.eth.getBalance(metamaskWallet).then(balance => console.log(balance))
  1. You can also run the comand below using the balance.js file (remember to configure the enviromental variables):
  node balance.js

image

  1. Deploy the contract into Ganache by connecting Remix IDE with your localhost:

image

image

image

  1. Update the index.html file with both addresses from Ganache and with the contract ABI from Remix (on the compiler tab). Remember to use your addresses.

image

image

  1. Test the application by updating the album details and see its changes on developer console:

image

image

  1. See that the contract don't let incoming changes if not contract owner (if you change myAccountNumber on the .js file to another address that didn't deployed the contract):

image

  1. At Remix IDE, deploy the contract on a test network (you will need a Metamask account):

image

image

  1. Test it by setting a new current album (at Remix IDE):

image

image

https://rinkeby.etherscan.io/address/0xca6542b455372f8bc63665cc3dbc0a6acc3f3871

image

Output

Here is an example of the smart contract in the blockchain and the transactions on Rinkeby. You can see the contract ABI on ./abi.json.

image

image

image

image

image

https://rinkeby.etherscan.io/tx/0xc89a3a5d8fd62b5016c50328da8899e3da01e5893664381e6459f78275498ab2

image

About

A simple blockchain project to show the basics of smart contracts and Ethereum development.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published