TAAS Protocol - Trust-as-a-Service Smart Contract
A decentralized escrow system for rental agreements on the TON blockchain, built with Blueprint framework and Tact smart contract language.
Overview
TAAS (Trust-as-a-Service) Protocol enables trustless rental agreements where security deposits are automatically staked to generate yield during the rental term. The protocol ensures both landlords and tenants benefit from a transparent, automated escrow system.
Key Features
🔒 Trustless Escrow System
- Automated deposit management
- Smart contract-enforced terms
- Multi-party agreement validation
💰 Yield Generation
- Security deposits are automatically staked
- 5% APY yield generation (configurable)
- Principal returned to tenant, yield to landlord
🎛️ Administrative Controls
- Owner-controlled pause/unpause functionality
- Agreement cancellation (before deposit)
- Event emissions for tracking
📊 Comprehensive Tracking
- Agreement status management
- Creation timestamps
- Event logging for all major actions
Agreement Lifecycle
1. Draft (0) → Landlord creates agreement
2. Accepted (1) → Tenant accepts terms
3. DepositReceived (2) → Deposit received by contract
4. DepositStaked (3) → Deposit automatically staked for yield
5. Completed (4) → Term ended, funds distributed
6. Cancelled (5) → Agreement cancelled (only before deposit)
Smart Contract Architecture
Core Contract: EscrowRegistry
Initialization: The contract is initialized with a unique ID that allows for multiple contract instances:
init(id: Int) {
self.id = id;
// ... other initialization
}
State Variables:
id: Unique identifier for the contract instance (uint32)agreementCounter: Total number of agreements createdagreements: Map of agreement ID to Agreement structyieldAdapter: Address of yield generation service (default set)jettonMaster: Address of USDT/stablecoin contract (default set)owner: Contract owner addresspaused: Emergency pause state
Message Types
CreateAgreement
Creates a new rental agreement.
{
tenant: Address;
depositAmount: bigint;
rentAmount: bigint;
startDate: bigint;
termLength: bigint;
}
AcceptAgreement
Tenant accepts the agreement terms.
{
agreementId: bigint;
}
DepositReceived
Triggered when deposit is received (keeper bot).
{
agreementId: bigint;
amount: bigint;
}
ClaimAtTermEnd
Processes agreement completion and fund distribution.
{
agreementId: bigint;
}
CancelAgreement
Cancels agreement before deposit is made.
{
agreementId: bigint;
}
SetPaused
Emergency pause control (owner only).
{
paused: boolean;
}
Getter Methods
getAgreement(agreementId): Get specific agreement detailsgetAgreementCounter(): Get total agreement countgetContractInfo(): Get contract metadata and statistics
Installation & Setup
Prerequisites
npm install -g @ton/blueprint
Clone and Install
git clone <repository-url>
cd taas-protocol/contract
npm install
Development Commands
Build Contract
npm run build
# or
npx blueprint build
Run Tests
npm test
Run Demo
npm run demo
Deploy Contract
npm run deploy
# or
npx blueprint run deployTaas
Testing
The project includes comprehensive test suites:
Basic Functionality Tests (Taas.spec.ts)
- Contract deployment
- Agreement creation and acceptance
- Deposit processing and staking
- Term completion and claiming
- Error handling and validation
Enhanced Features Tests (Enhanced.spec.ts)
- Contract information retrieval
- Parameter validation
- Agreement cancellation
- Pause/unpause functionality
- Ownership controls
- Timestamp tracking
Run All Tests
npm test
Expected output:
Test Suites: 2 passed, 2 total
Tests: 16 passed, 16 total
Demo Workflow
Run the interactive demo to see the complete protocol workflow:
npm run demo
The demo demonstrates:
- Contract deployment
- Agreement creation by landlord
- Agreement acceptance by tenant
- Deposit processing and staking
- Term completion and fund distribution
Contract Deployment
Testnet Deployment
- Configure your wallet in Blueprint
- Update yield adapter and jetton master addresses in deployment script
- Run deployment:
npx blueprint run deployTaas --testnet
Mainnet Deployment
npx blueprint run deployTaas --mainnet
Security Features
Input Validation
- Positive amounts required for deposits and rent
- Future start dates only
- Non-zero term lengths
- Address validation
Access Controls
- Only tenants can accept agreements
- Only parties can cancel agreements
- Only owner can pause contract
- Time-locked claim mechanisms
Emergency Controls
- Contract pause functionality
- Agreement cancellation (before deposit)
- Owner-controlled emergency stops
Gas Costs
Typical gas costs for operations:
- Deploy Contract: ~0.05 TON
- Create Agreement: ~0.05 TON
- Accept Agreement: ~0.05 TON
- Process Deposit: ~0.05 TON
- Claim at Term End: ~0.05 TON
Integration Examples
Frontend Integration
import { EscrowRegistry } from './build/Taas/Taas_EscrowRegistry';
import { toNano } from '@ton/core';
// Initialize contract with unique ID
const contractId = 1n; // Choose unique ID for your deployment
const escrowRegistry = provider.open(
await EscrowRegistry.fromInit(contractId)
);
// Create agreement
await escrowRegistry.send(
landlord.getSender(),
{ value: toNano('0.05') },
{
$$type: 'CreateAgreement',
tenant: tenantAddress,
depositAmount: toNano('1000'),
rentAmount: toNano('100'),
startDate: BigInt(Math.floor(Date.now() / 1000)),
termLength: BigInt(365 * 24 * 60 * 60),
}
);
// Get contract info including ID
const info = await escrowRegistry.getGetContractInfo();
console.log('Contract ID:', info.id);
Event Monitoring
The contract emits events for:
AgreementCreatedAgreementAcceptedDepositStakedAgreementCompleted
Configuration
Environment Variables
Create a .env file:
YIELD_ADAPTER_ADDRESS=EQ...
JETTON_MASTER_ADDRESS=EQ...
OWNER_MNEMONIC="your wallet mnemonic"
Network Configuration
Update tact.config.json for different networks:
{
"projects": [
{
"name": "Taas",
"path": "./contracts/taas.tact",
"output": "./build",
"options": {
"debug": true
}
}
]
}
Roadmap
Phase 1 ✅
- Basic escrow functionality
- Agreement lifecycle management
- Yield generation mechanism
- Comprehensive testing
Phase 2 🚧
- Multi-token support
- Advanced yield strategies
- Insurance mechanisms
- Dispute resolution
Phase 3 📋
- Mobile app integration
- Property verification oracles
- Credit scoring system
- DAO governance
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
For questions and support:
- Create an issue on GitHub
- Join our Telegram community
- Read the documentation
Built with 💚 on TON Blockchain using Blueprint Framework

