Skip to content

Latest commit

 

History

History
243 lines (180 loc) · 11.1 KB

File metadata and controls

243 lines (180 loc) · 11.1 KB

Decentralized Property Ownership Product.

Build Status

This project is a decentralized property ownership product using ERC-721 Tokens and zkSNARKS for zero knowledge proof of ownership.

Truffle version and OpenZeppelin version used in the project.

This project was built using the following framework versions:

  • Truffle v5.1.14-nodeLTS.0 (core: 5.1.13)
  • Ganache CLI v6.9.1 (ganache-core: 2.10.2)
  • OpenZeppelin (openzeppelin-solidity) v2.5.1
  • Solidity v0.5.16 (solc-js)
  • Node v12.18.1
  • Web3.js v1.2.1
  • Truffle Assertions v0.9.2

Running tests

To run the test suite for the smart contracts:

  1. Clone this repo
  2. Change into the project directory cd Udacity-Blockchain-Capstone/
  3. Ensure you already have npm v6.14.5 and node v12.18.1 installed.
  4. Install dependenceis npm i
  5. Install Ganache CLI npm i -g ganache-cli
  6. Install Truffle npm i -g truffle@nodeLTS
  7. Check truffle version by running truffle version.
  8. Change into the eth-contracts directory cd eth-contracts
  9. Create an empty .secret file touch .secret
  10. Compile the contracts truffle compile
  11. In one terminal window, start ganache-cli ganache-cli
  12. In a separate terminal window, run the smart contract specs via truffle test

After following the above process, you should see all the tests passing as they are on Travis CI.

ZoKrates

This project uses ZoKrates for implementing zkSNARKS. To run ZoKrates in a Docker Container, run the following command:

docker run -v $(pwd)/zokrates/code:/home/zokrates/code -ti zokrates/zokrates:0.4.6 /bin/bash

In the running container terminal execute the following commands to compile the proof code, setup and export the verifier contract.

cd code/square
~/zokrates compile -i ./code/zokrates/code/square/
~/zokrates setup
~/zokrates export-verifier

Now generate 10 different unique proofs ready for the NFT minting process:

~/zokrates compute-witness -a 1 1
~/zokrates generate-proof
mv proof.json proof1.json
~/zokrates compute-witness -a 2 4
~/zokrates generate-proof
mv proof.json proof2.json
~/zokrates compute-witness -a 3 9
~/zokrates generate-proof
mv proof.json proof3.json
~/zokrates compute-witness -a 4 16
~/zokrates generate-proof
mv proof.json proof4.json
~/zokrates compute-witness -a 5 25
~/zokrates generate-proof
mv proof.json proof5.json
~/zokrates compute-witness -a 6 36
~/zokrates generate-proof
mv proof.json proof6.json
~/zokrates compute-witness -a 7 49
~/zokrates generate-proof
mv proof.json proof7.json
~/zokrates compute-witness -a 8 64
~/zokrates generate-proof
mv proof.json proof8.json
~/zokrates compute-witness -a 9 81
~/zokrates generate-proof
mv proof.json proof9.json
~/zokrates compute-witness -a 10 100
~/zokrates generate-proof
mv proof.json proof10.json

Deployed contrats to Rinkeby

Use an Infura project to deploy to Rinkeby. Take a look in truffle-config file to see the Rinkby network configuration.

To migrate contracts to the Rinkeby network run:

truffle migrate --network rinkeby

The Verifier and SolnSquareVerifier Contracts are already deployed to Rinkeby at the following addresses:

Below are the truffle migration logs for the contract deployments:

Deploying 'Verifier'
   --------------------
   > transaction hash:    0x35528c5267a4838e9d290aa6a2d8e45085f286843725e6b23956f67a1faf765c
   > Blocks: 0            Seconds: 5
   > contract address:    0x32F13a3Cd59dDC8148deE0CD1B8fACbcA5D93794
   > block number:        6703297
   > block timestamp:     1592704929
   > account:             0x3aD2405264636d19F2869F4580c68391744EBCA1
   > balance:             18.32067154
   > gas used:            1013474 (0xf76e2)
   > gas price:           10 gwei
   > value sent:          0 ETH
   > total cost:          0.01013474 ETH


Deploying 'SolnSquareVerifier'
------------------------------
   > transaction hash:    0x4b0d8d29ac704365283f0c61cb9474463797a61430c7f1ac3ed3be39c64a85d1
   > Blocks: 2            Seconds: 21
   > contract address:    0x70797237915074795Adc107F3751710c6eE58e4f
   > block number:        6703299
   > block timestamp:     1592704959
   > account:             0x3aD2405264636d19F2869F4580c68391744EBCA1
   > balance:             18.28387767
   > gas used:            3679387 (0x38249b)
   > gas price:           10 gwei
   > value sent:          0 ETH
   > total cost:          0.03679387 ETH

Contract ABIs

Below are links to the contract ABIs:

Mint tokens via MyEtherWallet

Steps to mint tokens via MEW

  1. Open MEW homepage.
  2. Select Access via MetaMask
  3. Make sure you are logged into MetaMask and connected to the Rinkeby network.
  4. Click Access My Wallet button
  5. Click Interact with Contract link
  6. Paste in the deployed contract address (e.g. 0x70797237915074795Adc107F3751710c6eE58e4f) and the SolnSquareVerifier Contract ABI.
  7. Select the mint function (NOT the mintNFT function!) so that you can mint 10 tokens to your own address on the Rinkby network without having to submit a proof. This is OK for the testing of this contract for this case.
  8. Paste your address from MetaMask into the To (address) field and the TokenID (unit256) field set to any number. Try 99 first for testing.
  9. Confirm the transaction with MetaMask
  10. View the transaction on Ethersacn.
  11. Continue to mint TokenIds 1 to 10.

Token KH_PROPERTY_TOKEN (KHPT) Etherscan Token Tracker

The deployed and minted KHPT Tokens can be viewed via the Etherscan Token Tracker here. This shows the total supply of tokens available and who owns them.

For example the TokenId 99 just minted above is viewable.

Create storefront on OpenSea

Once the contract is deployed and tokens are minted, its possible to display them on via an OpenSea storefront. Steps to do this are as follows:

  1. Open the get listed page on OpenSea.
  2. Enter the deployed SolnSquareVerifier contract address.
  3. This will magically generate a storefront like this one for the KH PROPERTY TOKEN.

Auction items in OpenSea

Once your storefront is created you can begin to auction your assets.

  1. Ensure that you are logged into MetaMask with the account that you used to mint the tokens earlier.
  2. Select each of the tokens one by one and click the Sell button.
  3. Set the price and other parameters as you see fit. For this example, I set all token prices to 0.1 ETH.
  4. A number of transactions will need to be performed the first time around then after that only a signed confirmation is required.

Purchase items in OpenSea

Once tokens are available for auction on OpenSea they can be purchased!

  1. Switch accounts in MetaMask to a different account to the current owner of all the tokens. Make sure that this account has some Ether!
  2. Select a property / token and now you should be asked if you want to buy it!
  3. Click Buy button, sign the transaction, wait for confirmation and now you are the new owner of this property / token.
  4. You can verify this transfer of ownership via the Etherscan Token Tracker

Trading activity on OpenSea

The trading activity for the KHPT tokens can be viewed in the OpenSea Activity Log for the KH_PROPERTY_TOKEN Stream.

The 5 purchased / sold / transfered tokens are:

The 5 unpurchased (still owned by the original contract owner) tokens are:

Issue Reporting

If you experience with bugs or need further improvement, please create a new issue under Issues.

Contributing to the Decentralized Property Ownership Product!

Pull requests are very welcome. Before submitting a pull request, please make sure that your changes are well tested. Pull requests without tests will not be accepted. In this project we currently use Truffle Tests (Mocha JS / Chai JS).

Authors

This Decentralized Property Ownership Product application was developed as part of the Blockchain Nanodegree with Udacity and Darren Jensen.

License

This Decentralized Property Ownership Product application is released under AGPL

Disclaimer

This application is part of a project assignment and is most definitely not suitable for Production use! :)

Project Resources