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.
- Clone this repository.
- 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.
- Install the dependencies with NodeJS and NPM.
- Test the application by updating the album details.
- 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.
- 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.
- Create an Infura account to publish the contracts into the Rinkeby Test Network.
- Install Truffle CLI. Truffle is the most popular development framework for Ethereum.
- 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.
- By testing the Album.sol smart contract on Remix you can compile and deploy it:
- 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))
- You can also run the comand below using the balance.js file (remember to configure the enviromental variables):
node balance.js
- Deploy the contract into Ganache by connecting Remix IDE with your localhost:
- 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.
- Test the application by updating the album details and see its changes on developer console:
- 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):
- At Remix IDE, deploy the contract on a test network (you will need a Metamask account):
- Test it by setting a new current album (at Remix IDE):
https://rinkeby.etherscan.io/address/0xca6542b455372f8bc63665cc3dbc0a6acc3f3871
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.
https://rinkeby.etherscan.io/tx/0xc89a3a5d8fd62b5016c50328da8899e3da01e5893664381e6459f78275498ab2