Skip to content

An Ethereum DApp for property claim by mint tokens on a real estate marketplace.

License

Notifications You must be signed in to change notification settings

ffrancis-reis/real-estate

Repository files navigation

Ethereum DApp for Property Claim by mint tokens on a Real Estate Marketplace

Introduction

This project consists in a decentralized application (DApp) for property claim by mint tokens on a real estate marketplace.

Important: The project was made with the versions below, since Truffle v5 comes with Solidity v0.5 with many changes concerning mutability and visibility.

  • Truffle v5.4.7 (core: 5.4.7)
  • Solidity v0.5.16 (solc-js)
  • Ganache CLI v6.12.2 (ganache-core: 2.13.2)
  • Node v13.14.0
  • Web3.js v1.5.2

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. Install the dependencies with NodeJS and NPM, and also install Docker to manage containers (needed for ZoKrates).
  3. Test the application making calls to the contract on the Rinkeby Test Network.
  4. Take a look at the transactions happening on the Rinkeby Test Network at Etherscan explorer.

Dependencies

  1. Create an Ethereum account. Ethereum is a decentralized platform that runs smart contracts.
  2. Create an account and install the Metamask extension on your web browser.
  3. Create an Infura account to publish the contracts into the Rinkeby Test Network.
  4. Install Truffle CLI. Truffle is the most popular development framework for Ethereum.
  5. Use this passphrase with Ganache command as a suggestion "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat". Ganache is part of the Truffle suite that you can use to run a personal Ethereum blockchain.
  6. Verify the contract with ZoKrates. ZoKrates is a toolbox for zkSNARKs on Ethereum that helps you by generating verifiable computation proofs in Solidity from your DApp.
  7. Mint tokens using MyEtherWallet and verify the tokens on OpenSea marketplace.

Important: You will need your personal passphrase from your Ethereum account to publish into the Rinkeby Test Network, hence the .secret file in the truffle-config.js, even tough being a test network.

Instructions

  1. Install the dependencies:
  npm i
  npm i -g ganache-cli
  npm i -g truffle
  1. Turn on the Ganache suite so that you will have pre-defined accounts to test the contracts:
  ganache-cli -m "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat"

image

  1. Compile, migrate and test the contracts with truffle (on a separate console). It will use the previously up and running ganache locally blockchain. Remember that the contracts are inside ./eth-contracts. You can either test with a specific test file or just test all of them.

Important: I would suggest re-running ganache-cli if you are having trouble to migrate the contracts, so that ganache reset the network, all the gas used, and else, because it does help sometimes.

  truffle compile
  truffle migrate
  truffle test ./test/TestERC721Mintable.js
  truffle test
  1. Implement Zokrates to verify proof. By running the command below Docker wil install ZoKrates 0.3.0 version and open it's shell to generate the proof flow:
  docker run -v [project folder]:/home/zokrates/code -ti zokrates/zokrates:0.3.0 /bin/bash

Inside ZoKrates shell run the commands below. Get on the square.code folder, compile and work on the flow untill you export the verifier.

  cd code/zokrates/code/square
  ~/zokrates compile -i square.code
  ~/zokrates setup
  ~/zokrates compute-witness -a 3 9
  ~/zokrates generate-proof
  ~/zokrates export-verifier

image

image

You can then test both TestSquareVerifier.js and TestSolnSquareVerifier.js files to prove ZoKrates verifiable computation.

  truffle test ./test/TestSquareVerifier.js
  truffle test ./test/TestSolnSquareVerifier.js
  truffle test

image

  1. Publish the contracts into the Rinkeby Test Network with your Infura key:
  truffle migrate --reset --network rinkeby

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.

Etherscan info:

image

Mint tokens:

image

OpenSea Storefront: https://testnets.opensea.io/konig-estate-marketchain

image

image

One of the estates: https://testnets.opensea.io/assets/0x052a650b979a8515b15b74ac7de31df8ece532ed/0

Selling process:

image

image

image

image

image

image

Buying process:

image

image

image

image

image

https://testnets.opensea.io/assets/0x052a650b979a8515b15b74ac7de31df8ece532ed/0

image

https://testnets.opensea.io/assets/0x052a650b979a8515b15b74ac7de31df8ece532ed/1

image

https://testnets.opensea.io/assets/0x052a650b979a8515b15b74ac7de31df8ece532ed/2

image

https://testnets.opensea.io/assets/0x052a650b979a8515b15b74ac7de31df8ece532ed/3

image

https://testnets.opensea.io/assets/0x052a650b979a8515b15b74ac7de31df8ece532ed/4

image