Skip to content

Star Notary decentralized application for the Ethereum network

License

Notifications You must be signed in to change notification settings

tamasdinh/starnotary-dapp

Repository files navigation

Ethereum-based Decentralized Token Notary Service App

The goal of the project was to build a simple end-to-end Ethereum-based blockchain notary solution for an ERC721 non-fungible token (i.e. a token whose instances have unique values, e.g. representing unique collectible assets).

The solution is a decentralized app, whose core components are:

  • Smart contract deployed in Ethereum's Rinkeby test network: smart contract written in Solidity that implements key token transactional and registry methods, building on the ERC721 token standard. It is part of the Ethereum blockchain and can be executed by any of the Ethereum nodes participating in the Rinkeby network.

  • JavaScript web app: provides a convenient way through a front-end application to create a new token, query existing tokens and tranfer tokens to Ethereum Rinkeby addresses. Built in the Truffle Framework in JavaScript, HTML and CSS.

Key component files of interest

  • /contracts/starNotary.sol: Solidity smart contract source code. Implements various token registry and transaction methods; built on, and in accordance with, the ERC721 non-fungible token standard.
  • /app/scripts/index.js: implements smart contract interaction functionality needed for the front-end to operate properly.
  • /app/index.html: implements simple front-end web page with create token, look up token by ID and transfer token functionality
  • /test/starNotary.js: unit tests for the Solidity smart contract - implemented in Mocha and Chai, leveraging Truffle's unique functionality for Solidity smart contracts.

Prerequisites and installing (examples for MacOS, but most of it should work on Windows as well)

To install the software, you need to do the following:

1. Install Node.JS on your computer - visit https://nodejs.org/en/ and choose installer for your system

2. Clone or download GitHub repo files into desired directory from https://github.com/tamasdinh/starnotary-dapp.git

mkdir project-folder
cd project-folder
git clone https://github.com/tamasdinh/starnotary-dapp.git

3. Install and save dependencies to project folder:

npm install -g truffle      # this is actually a global install
npm install openzeppelin-solidity --save    # this is needed for ERC721 contracts
npm install truffle-hdwallet-provider --save # wallet provider for deployment to Ethereum network

You might run into trouble installing truffle globally. Alternatively to the above solution, you could use

sudo npm install -g truffle

4. Install Ethereum wallet provider Metamask (see instructions here) plugin for your browser (Google Chrome or Brave)

5. Create new account with Metamask (Metamask will take you through the process)

Running and testing the smart contract and the web app

1. Once you have Truffle installed, you can start the Truffle develop console - this will initialize a local Ethereum blockchain at (http://127.0.0.1:9545) with 10 accounts, each with a balance of 100 ether and open the Truffle develop console for you.

truffle develop

2. Run test script against smart contract - this will show you what unit tests have been defined and whether they all pass on the contract:

test

3. Compile and migrate contracts to the local test network:

compile
migrate --reset --network develop # this will automatically target the development network as I already fixed its parameters in the config file truffle.js

4. Set up Metamask to connect to local development network:

  • go to Metamask plugin, click on active network, select Custom RPC and enter http://127.0.0.1:9545 under 'Custom RPC settings')
  • please disable Privacy Mode under Settings. DO NOT FORGET to turn this back on before interacting with live Ethereum sites!
  • add one or multiple local development network accounts to Metamask - click on Import Account and paste private key of selected local dev account (you can see the list of account addresses and corresponding private keys in the Terminal window in which you used the Truffle develop console.)

5. Start web app on development network - open new bash Terminal window:

npm run dev

This will start the web app at http://localhost:8080. Navigate to this page through the web browser in which you have the Metamask plugin (e.g. Google Chrome). You can try out the functionalities provided on the front-end with an account you imported from the local dev network.

Built With

  • Node.js - The JavaScript runtime used
  • Truffle Framework - JavaScript framework used for testing, compiling and deploying contracts, as well as interacting with the deployed contract from the web app
  • Web3.js - Ethereum JavaScript API; used as part of Truffle workflow to enable querying of accounts in network
  • Infura - Used to deploy contract on the live net (Infura has nodes in Ethereum, and through the service we can use these nodes to deploy contracts, without having to have our own node in the Ethereum network)
  • Metamask - Ethereum wallet provider used
  • MS Visual Studio Code - Code editor used for scripting
  • VSCode Solidity extension - GitHub - Juan Blanco's excellent Solidity Language Extension for VSCode

Authors

About

Star Notary decentralized application for the Ethereum network

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published