LandReg is a standalone smart contract that can be used to run a land registry. Plus, any user can lend money to any other user to buy one property. Each Property is identified by its PIN(int). This is a prototype for a dApp that would allow a state to deal with its land registry using smart contracts (dealing with ownership, sales, taxes etc...)
It is written in Solidity and compiled using solc
version 0.5.0.
It can be deployed to an Ethereum blockchain, be it the public mainnet, a public testnet like Rinkeby, a private blockchain, or on a local development blockchain like Ganache.
It uses Ethereum's native Ether for and fees and payments required.
The Land Registry contracts manages a few features:
- Add a Property - Any user can add a property to the registry
- Update a Property - The contract owner can update a property to the registry
- Delete a Property - The contract owner can delete a property to the registry
- Submit a transaction - Any user can lend ether to any other user to transfer the ownership a property. For the ownership of the property to be transfer, every party (lender of the money, the receiver that wants to buy a property and the seller of that property) has to confirm the transaction. The smart contracts update directly the registry.
- Confirm a transaction Any user involved in a transaction can sign transaction it.
- Revoke a transaction If you have changed your mind after having confirmed the transaction before all the parties have signed the transaction, you can revoke your confirmation.
A list of possible enhancements for this contract are:
- Implement a regularly payback from the one who receiver the money to the lender
- Implement a multi-ownership properties
- Use a token to represent a property
Land Registry was developed as my final project for the ConsenSys Academy Developer Program Bootcamp.
This section provides a high-level requirement & quick start guide. For detailed installations, such as getting started with Docker, or specific operating systems
- node : This should install both Node.js and npm
- ganache the command line, but I recommend the GUI (https://www.trufflesuite.com/ganache)
- truffle
- metamask
Get a look also at section docker Installation.
-
Make sure all the prerequisites are installed
-
Clone the repository, ie
git clone https://github.com/Iskander54/final_ethereum
-
Go into ./landreg and type
npm install
to install dependencies of the Solidity backend -
Go into ./client and type
npm install
to install dependencies of the ReactJS frontend
- You can run
truffle test
in the landreg folder to run the truffles tests.
-
Launch ganache on port 8545
-
Make sure your Metamask is link to local network port 8545.
-
Go into ./landreg and
truffle migrate
to push the contracts on the blockchain. By default would be pushed on development server(127.0.0.1:8545) in truffle-config.js . -
Go into ./client and
npm run start
to launch the dev server (local port is 8545 in getWeb3.js, you can change it if needed) -
You can import the accounts on Metamask using the private keys provided by your ganache. If you have trouble using Metamask you can see this tutorial.
-
Open your browser where Metamask is installed and go on localhost:3000 ( Port may have change, check the npm run start logs)
- Docker
- Docker-compose: write the configuration of your containers in a
docker-compose.yml
file
-
Clone the repository, ie
git clone https://github.com/Iskander54/final_ethereum
-
Go into the repository and type
docker-compose build
to build the image -
Type
docker-compose up
to launch the app -
Make sure your Metamask is link to local network port 8545.
-
While the docker is building and deploying, you can import the accounts on Metamask using the private keys provided below. If you have trouble using Metamask you can see this tutorial.
Accounts | Private keys |
---|---|
0x42CAD0CA3716b4664c2658A0a48664369D511C54 | 80d7110b676b1cb7f719bc7aa639a10a6d1611f1bd5ff7e94995da52915710de |
0xDf7064894A0da6b741b86104af7875647b7767A3 | ae327c532fcc5254b701ca2a10f198787b93d37fe5c78cfe8531ce4373aa182e |
0x229846d7818D13a468cB9767c04e375a82CE0e3D | 85b4ae0e89b5dd0ac460dcf1806af39c0ce59ee567f56d520ba1c0144a5a1537 |
0x62bCb1BAa29f52b5CE165Db1A6aCEA9972b2f643 | d42e7182f3dda9b1b0353e083c178930bf169073a8b4634cc96cfcc48cd896b9 |
- Wait for the docker to be up and Go to your browser on localhost:3001
You can run the dApp with your own ganache, to do so :
-
Clone the repository, ie
git clone https://github.com/Iskander54/final_ethereum
-
Go in the
final_ethereum/landreg
-
Type
docker build -t landreg .
-
Type
docker run -e [HOST=XXXX, PORT=XXXX, NETWORKID=XXXX] landreg
using the corresponding ganache parameters (you can see the default environment variable in the dockerfile used for docker-compose)
In the docker-compose, Only 4 accounts have been imported :
Accounts | Private keys |
---|
| 0x42CAD0CA3716b4664c2658A0a48664369D511C54 | 80d7110b676b1cb7f719bc7aa639a10a6d1611f1bd5ff7e94995da52915710de | | 0xDf7064894A0da6b741b86104af7875647b7767A3 | ae327c532fcc5254b701ca2a10f198787b93d37fe5c78cfe8531ce4373aa182e | | 0x229846d7818D13a468cB9767c04e375a82CE0e3D | 85b4ae0e89b5dd0ac460dcf1806af39c0ce59ee567f56d520ba1c0144a5a1537 | | 0x62bCb1BAa29f52b5CE165Db1A6aCEA9972b2f643 | d42e7182f3dda9b1b0353e083c178930bf169073a8b4634cc96cfcc48cd896b9 |
Metamask can have some issues. Make sure to properly connect to the local network once ganache is launched(don't hesitate to switch to another network and come back). If you get the " RPC Error: Error: [ethjs-rpc]rpc error with payload" using Metamask, that means that you have to reset all your accounts and launch again the dApp.
You may encounter two errors while building the container, you don't need to take them into account, be sure that the build is succesful. If not, this mays real errors.
- A README.md that explains the project
- What does it do?
- How to set it up.
- How to run a local development server.
- It should be a Truffle project.
- All contracts should be in a
contracts
directory.-
truffle compile
should successfully compile contracts.
-
- Migration contract and migration scripts should work.
-
truffle migrate
should successfully migrate contracts to a locally runningganache-cli
test blockchain on port8454
.
-
- All tests should be in a
tests
directory.-
truffle test
should migrate contracts and run the tests.
-
- All contracts should be in a
- Smart contract code should be commented according to the specs in the documentation.
- Create at least 5 tests for each smart contract.
- Write a sentence or two explaining what the tests are covering, and explain why those tests were written.
- A development server to serve the front-end interface of the application.
- It can be something as simple as the lite-server used in the Truffle Pet Shop tutorial.
- A document design_pattern_decision.md that explains the design patterns chosen.
- A document avoiding_common_attacks.md that explains what measures were taken to ensure that the contracts are not susceptible to common attacks.
- Implement/use a library or an EthPM package.
- If the project does not require a library or an EthPM package, demonstrate how it would do that in a contract called
LibraryDemo.sol
.
- If the project does not require a library or an EthPM package, demonstrate how it would do that in a contract called
- Develop your application and run the other projects during evaluation in a VirtualBox VM running Ubuntu 16.04 to reduce the chances of runtime environment variables.
- Run the dapp on a development server locally for testing and grading.
- You should be able to visit a URL and interact with the application:
- App recognizes current account;
- Sign transactions using MetaMask or uPort;
- Contract state is updated;
- Update reflected in UI.
- Write 5 tests for each contract you wrote;
- Solidity or JavaScript.
- Explain why you wrote those tests;
- Tests run with
truffle test
.
- Tests run with
- Implement a circuit breaker (emergency stop) pattern.
- What other design patterns have you used / not used?
- Why did you choose the patterns that you did?
- Why not others?
- Explain what measures you have taken to ensure that your contracts are not susceptible to common attacks.
- Via EthPM or write your own.
- Deploy your application onto one of the test networks.
- Include a document called deployed_addresses.txt that describes where your contracts live (which testnet and address).
- Students can verify their source code using Etherscan https://etherscan.io/verifyContract for the appropriate testnet.
- Evaluators can check by getting the provided contract ABI and calling a function on the deployed contract at https://www.myetherwallet.com/#contracts or checking the verification on Etherscan.
-
Implement an upgradable design pattern.
-
Write a smart contract in LLL or Vyper.
-
Integrate with an additional service. For example:
- IPFS - users can dynamically upload documents to IPFS that are referenced via their smart contract.
- uPort
- Ethereum Name Service - a name registered on the ENS resolves to the contract, verifiable on
https://rinkeby.etherscan.io/<contract_name>
- Oracle
-
Alex-Kevin LOEMBE, loembe.ak@gmail.com , Iskander54