This PR implements a comprehensive tax jurisdiction mapping system that transforms Grant-Stream into a "Tax-Native" protocol capable of handling global tax compliance for a distributed workforce of developers while maintaining legal standing with international tax authorities.
- ✅ GranteeRecord Enhancement: Added
jurisdiction_codefield to track tax jurisdictions - ✅ Jurisdiction Registry: Implemented DAO-updatable registry for global tax rates
- ✅ Dynamic Tax Withholding: Tax rates automatically adjust based on jurisdiction
- ✅ Tax Treaty Support: Built-in support for tax treaty benefits
- ✅ Comprehensive Testing: Full test suite covering all scenarios
-
JurisdictionInfo Structure
pub struct JurisdictionInfo { pub code: String, // e.g., "US-CA", "GB-LDN" pub name: String, // Human-readable name pub tax_withholding_rate: u32, // Rate in basis points (1/100%) pub tax_treaty_eligible: bool, // Treaty benefits available pub documentation_required: bool, // Additional docs needed pub updated_at: u64, // Last update timestamp pub updated_by: Address, // Who updated this }
-
GranteeRecord Structure
pub struct GranteeRecord { pub address: Address, // Wallet address pub jurisdiction_code: String, // Tax jurisdiction pub tax_id: Option<String>, // SSN, EIN, etc. pub tax_treaty_claimed: bool, // Treaty benefits claimed pub verified: bool, // Verification status pub verification_documents: Option<[u8; 32]>, // Document hash pub created_at: u64, // Creation time pub updated_at: u64, // Last update }
-
TaxWithholdingRecord Structure
pub struct TaxWithholdingRecord { pub grant_id: u64, // Associated grant pub grantee: Address, // Grantee address pub gross_amount: i128, // Gross payment pub tax_rate: u32, // Applied tax rate pub tax_withheld: i128, // Amount withheld pub net_amount: i128, // Net payment pub jurisdiction_code: String, // Jurisdiction used pub payment_date: u64, // Payment timestamp pub tax_report_id: Option<u64>, // Report reference }
register_jurisdiction(): Admin-only jurisdiction registrationupdate_jurisdiction(): Dynamic jurisdiction updates by DAOset_tax_withholding_reserve(): Configure tax reserve address
register_grantee_jurisdiction(): Self-service jurisdiction registrationget_grantee_record(): Retrieve grantee tax information
calculate_tax_withholding(): Real-time tax calculationprocess_payment_with_tax(): Automated tax withholding
get_jurisdiction(): Retrieve jurisdiction detailsget_all_jurisdictions(): List all registered jurisdictions
The system implements sophisticated tax calculation:
- Base Rate Application: Applies jurisdiction-specific base rate
- Treaty Benefits: 50% reduction for eligible treaty claims
- Validation: Ensures rates stay within configured bounds
- Transparency: Full audit trail of all calculations
Example calculation:
- Gross Amount: $1,000
- US-CA Base Rate: 30% (3000 basis points)
- Treaty Benefits: Yes (50% reduction)
- Effective Rate: 15% (1500 basis points)
- Tax Withheld: $150
- Net Payment: $850
- Jurisdiction code length limits (max 10 chars)
- Tax rate bounds (0-50% maximum)
- Required field validation
- Admin-only jurisdiction registration/updates
- Grantee self-service for own records
- DAO governance for registry changes
- Timestamped updates
- Updater address tracking
- Complete payment history
// Tax Jurisdiction keys
JurisdictionRegistry(String), // Code → JurisdictionInfo
JurisdictionCodes, // List of all codes
GranteeJurisdiction(Address), // Address → GranteeRecord
TaxWithholdingReserve, // Reserve addressComprehensive test suite includes:
- ✅ Jurisdiction registration and updates
- ✅ Grantee jurisdiction registration
- ✅ Tax withholding calculations
- ✅ Payment processing with tax
- ✅ Tax treaty benefits
- ✅ Input validation and error scenarios
- ✅ Edge cases and boundary conditions
This implementation enables Grant-Stream to:
- Handle Multi-Jurisdictional Workforce: Support developers from any country
- Maintain Legal Compliance: Automatic tax withholding per local laws
- Adapt to Regulatory Changes: DAO can update rates as laws evolve
- Provide Tax Transparency: Clear reporting for grantee and foundation
- Support Tax Treaties: Reduce withholding for treaty beneficiaries
- Predictable net payments regardless of location
- Automatic tax treaty benefit application
- Clear tax documentation for filing
- Compliance with international tax laws
- Automated tax withholding and reporting
- Reduced legal and administrative overhead
- "Tax-Native" positioning enhances adoption
- DAO-governed tax policy ensures adaptability
- Transparent operations build trust
Potential future improvements:
- Tax reporting integration with accounting systems
- Multi-currency tax withholding
- Advanced tax treaty calculations
- Automated tax filing assistance
- Integration with tax oracle services
- Data structures defined
- Core functions implemented
- Access controls configured
- Tax calculation logic
- Payment processing with tax
- DAO governance functions
- Comprehensive test suite
- Error handling and validation
- Event emissions for transparency
- Storage optimization
- Initialization: Admin must set up initial jurisdictions
- Reserve Configuration: Tax withholding reserve address required
- Grantee Onboarding: Users register their jurisdiction
- Monitoring: DAO oversees jurisdiction registry updates
- Function documentation included in code
- Test cases serve as usage examples
- Constants clearly defined for easy modification
- Error codes comprehensive for debugging
This PR establishes Grant-Stream as a truly global, tax-compliant funding protocol ready for international deployment.