The Digital Property Smart Contract is a blockchain-based solution designed for registering and managing ownership of digital or real-world assets. Built with Solidity, this contract ensures transparency, security, and immutability in asset ownership and transfers.
This project was developed and tested using Remix IDE, making it easy to deploy and interact with the smart contract directly in a web browser.
- Asset Registration: Allows users to register properties with a unique ID and description.
- Ownership Transfer: Owners can transfer properties to other users securely.
- Ownership Verification: Anyone can verify the current owner of a property.
- Event Logging: All important actions, such as registration and transfer, trigger blockchain events for transparency.
-
registerProperty(uint256 id, string memory description)
- Registers a property with a unique identifier and description.
- Emits the
PropertyRegistered
event.
-
transferOwnership(uint256 id, address newOwner)
- Transfers ownership of a registered property to another user.
- Emits the
OwnershipTransferred
event.
-
getProperty(uint256 id)
- Retrieves details of a registered property, including its ID, description, and current owner.
PropertyRegistered(uint256 id, string description, address owner)
OwnershipTransferred(uint256 id, address previousOwner, address newOwner)
fallback()
: Handles unexpected or undefined function calls.receive()
: Allows the contract to receive ether directly.
- Remix IDE: Accessible via https://remix.ethereum.org.
-
Open Remix IDE
- Go to Remix IDE.
-
Create the Smart Contract File
- In the File Explorer, create a new file (e.g.,
PropertyRegistry.sol
). - Copy and paste the smart contract code into the file.
- In the File Explorer, create a new file (e.g.,
-
Compile the Contract
- Navigate to the Solidity Compiler tab.
- Select a compiler version compatible with the code (e.g.,
0.8.x
), in my case i used 0.8.24 . - Click Compile PropertyRegistry.sol.
-
Deploy the Contract
- Go to the Deploy & Run Transactions tab.
- Select the environment:
- Remix VM (Cancun) for local testing.
- Click Deploy to deploy the contract.
-
Interact with the Contract
- Use the deployed contract interface to call functions like
registerProperty
andtransferOwnership
.
- Use the deployed contract interface to call functions like
-
Basic Registration
- Call
registerProperty
with:id = 1
description = "House in Marbella"
- Use
getProperty(1)
to confirm that the property is correctly stored.
- Call
-
Ownership Transfer
- Call
transferOwnership
on a registered property to transfer ownership to another address. - Verify that the ownership has changed using
getProperty
.
- Call
-
Duplicate IDs
- Try registering another property with the same ID. The contract should reject the transaction.
-
Unauthorized Access
- Attempt to transfer ownership of a property from a non-owner account. The transaction should fail.
-
Invalid Addresses
- Test transferring a property to the
0x0
address. The contract should reject the transaction.
- Test transferring a property to the
-
High and Low IDs
- Register properties with extremely high or low ID values (e.g.,
0
,2**256 - 1
).
- Register properties with extremely high or low ID values (e.g.,
-
Long Descriptions
- Register a property with a very long description to check if the contract handles large strings.
registerProperty(1, "Apartment in Barcelona");
transferOwnership(1, 0x123456789abcdef123456789abcdef123456789a);
getProperty(1);
- Metadata Integration: Add ERC-721 standards to include metadata for properties.
- KYC System: Introduce user verification before registering or transferring properties.
- Multi-Signature Transfers: Enable multi-signature approvals for high-value properties.
This project is licensed under the LGPL-3.0-only.
A clear and interactive UI could be built using frameworks like React.js to interact with this contract for enhanced user experience. For now, enjoy the simplicity and power of Remix IDE! 🚀