Using Python to build a solution for instant tokenized real estate redemptions
Lofty is a startup enabling users to turn the equity of real estate properties into digital tokens, which are then available for peer-to-peer trading on a secondary marketplace. In practice, it enables real estate to be traded similarly to more liquid assets like stocks. To date, more than 180 properties have been tokenized on the platform, generating $3M+ in rental income for users.
To achieve its vision for a future where real estate is more easily tradeable and investable, Lofty utilizes Algorand – a Layer-1 blockchain with native Python programmability. While the core of the platform’s smart contracts were developed in an older Algorand programming language (TEAL), the team has shifted to developing new features in Python, including a smart contract released this year that enables users to instantly redeem tokens for the value of a sold property share.
Smart contracts are self-contained programs that validate transactions according to predefined rules and parameters. They are a commonly utilized tool on decentralized blockchain networks such as Algorand and Ethereum. For Lofty, smart contracts are used for all transactions, including limit orders and market orders. The former enables peer-to-peer swaps routed by Lofty, so while users experience a seamless trading experience, their funds are settled directly between buyers and sellers, never touching Lofty’s accounts. The latter enables liquidity pools to act as a counterparty to buyers and sellers, enabling instant liquid transactions from real estate. The liquidity pools themselves are also smart contract-based escrow accounts.
It took the Lofty engineering team only one week to build the smart contracts for the new token redemption feature. Python programmability on Algorand makes the entire development lifecycle easier and means more affordable and efficient maintenance and upgrades going forward. Specific benefits of Algorand Python (algopy
) versus other blockchain-specific languages include:
- Natural Python syntax using standard Python class structures, making code more readable and maintainable
- Strong typing system with proper classes and inheritance, just as one would use in regular Python
- Intuitive method decorators like
@abimethod
and@subroutine
that clearly define the contract’s external method entry points vs. internal methods - Simplified on-chain transaction handling with helper classes like AssetTransfer
- Abstraction of Algorand-specific data concepts through Python classes like
Asset
andAccount
- Familiar object-oriented programming patterns, making contracts more accessible to Python developers without specialized smart contract expertise
- Ability to use testing, linting, formatting, and other familiar Python libraries with smart contract code
In the following example, a smart contract is written in Python to facilitate token swaps. The Swap contract allows users to exchange one token for another at a fixed 1:2 ratio. The contract maintains separate incoming and outgoing asset pools, provides administrative functions for the governor, and includes safety checks to ensure sufficient liquidity before processing swaps.
Code:
By building its new smart contracts in Python, and tapping into Algorand’s broader suite of developer tools like AlgoKit, Lofty is able to easily and affordably maintain its code as the company scales and introduces new features.
Lofty’s tokenized real estate marketplace could not exist without blockchain. By building on the decentralized, open-source, and efficient Algorand network, Lofty users benefit from instant transaction finality, a 5+ year history of 100% network uptime, and global scalability (able to settle 10,000 transactions per second) – all at the cost of just fractions of a penny each. In addition, Algorand offers native features like atomic transactions and multisig capabilities, which are central to Lofty’s platform. Atomic transactions enable trustless transactions between users, giving them the experience and feel of a centralized exchange while ensuring that actual funds are settled safely in a peer-to-peer way, while native multisig allowed Lofty to build embedded wallets that users operate on their account dashboard. This enables anyone to immediately start using a blockchain-based product, regardless of any prior understanding of blockchain concepts.
Algorand is the only Layer-1 network offering native Python programmability, giving developers a simple path to unlocking the powerful possibilities of decentralized blockchain for all types of industries.
DISCLAIMER: The content provided herein is for informational purposes only. The information is provided by the Algorand Foundation. While we strive to ensure the information is up-to-date and correct, we make no representations or warranties, express or implied, about its completeness, accuracy, reliability, suitability, or availability for any purpose. This article is not intended to be financial advice. You should not take any action before conducting your own research or consulting with a qualified professional. Any reliance you place on such information is strictly at your own risk. The Algorand Foundation shall not be liable for any loss or damage, including but not limited to indirect or consequential loss, loss of data, or loss of profits, arising out of or in connection with the use of this article.