A comprehensive IP-NFT tokenization platform for agricultural biotechnology intellectual property, built on Kasplex testnet (Layer 2 zkEVM for Kaspa). This system enables the tokenization of bacterial pesticide alternatives with automated royalty distributions and fractional ownership.
This project implements a MoleculeDAO-inspired architecture for agricultural biotech IP, specifically designed for bacterial pesticide alternatives. It provides:
- IP-NFT Tokenization: ERC-721 based NFTs representing agricultural IP with detailed metadata
- Fractional Ownership: Convert IP-NFTs into tradeable ERC-20 governance tokens
- Automated Royalties: Pull-based payment system for multi-beneficiary distributions
- Governance: On-chain voting for IP licensing decisions
-
AgriculturalIPNFT.sol
- ERC-721 NFT with ERC-2981 royalty standard
- Stores crop species, bacterial strain, regulatory approvals, licensed acreage
- Role-based access control (MINTER_ROLE, LICENSING_ROLE)
- Pausable for emergency situations
- UUPS upgradeable
-
IPTokenizer.sol
- Fractionalizes IP-NFTs into ERC-20 tokens
- ERC20Votes for governance
- Revenue distribution to token holders
- Proposal and voting system
- Redemption/buyout mechanism
-
RoyaltyDistributor.sol
- Multi-beneficiary royalty splitting
- Pull-based payments (gas optimized)
- Compliance tracking
- Supports up to 50 beneficiaries per IP
- Event Monitor: Real-time blockchain event monitoring
- REST API: Contract interaction endpoints
- Database: MongoDB for event storage and analytics
- Foundry (installed automatically in setup)
- Node.js >= 18.0.0
- MongoDB (optional, for backend)
- Kasplex Testnet access
# Clone the repository
git clone <your-repo-url>
cd KasplexSC
# Install Node.js dependencies
npm install
# Create environment file
cp .env.example .env
# Edit .env with your configuration
# IMPORTANT: Add your private key and contract addresses
nano .env# Compile all contracts
forge build
# Run tests
forge test
# Generate gas report
forge test --gas-report
# Generate coverage report
forge coverage# 1. Get testnet KAS from faucet
# Visit: https://faucet.kasplextest.xyz/
# 2. Deploy core contracts
forge script script/Deploy.s.sol:DeployScript \
--rpc-url $KASPLEX_RPC_URL \
--broadcast \
--verify \
-vvvv
# 3. Save the deployed contract addresses to .env
# 4. Mint an IP-NFT (using cast or frontend)
# 5. Deploy tokenizer for specific IP-NFT
export TOKEN_ID=0
export IPNFT_ADDRESS=<your-ipnft-address>
forge script script/Deploy.s.sol:DeployIPTokenizer \
--rpc-url $KASPLEX_RPC_URL \
--broadcast \
-vvvv# Start MongoDB (if using database features)
mongod
# Start backend server
npm run backend:dev
# The API will be available at http://localhost:3000Kasplex Testnet
- RPC URL:
https://rpc.kasplextest.xyz - Chain ID:
167012(0x28C94) - Currency: KAS
- Block Explorer:
https://frontend.kasplextest.xyz - Faucet:
https://faucet.kasplextest.xyz/
Add to MetaMask:
- Network Name: Kasplex Testnet
- RPC URL: https://rpc.kasplextest.xyz
- Chain ID: 167012
- Currency Symbol: KAS
- Block Explorer: https://frontend.kasplextest.xyz
// Using ethers.js
const tx = await ipnftContract.mintIPNFT(
ownerAddress,
"Corn", // Crop species
"Bacillus thuringiensis", // Bacterial strain
"FDA Approved", // Regulatory status
"Iowa State University", // Research institution
"ipfs://QmMetadata...", // Metadata URI
royaltyReceiverAddress, // Royalty receiver
500 // 5% royalty (in basis points)
);// Deploy tokenizer for specific IP-NFT
const tokenizerFactory = await ethers.getContractFactory("IPTokenizer");
const tokenizer = await tokenizerFactory.deploy();
await tokenizer.initialize(
ipnftAddress,
tokenId,
ethers.parseEther("1000000"), // 1M fractional tokens
"Agricultural IP Token",
"AGRI-IPT",
initialOwnerAddress,
5100 // 51% quorum
);// Create a proposal
const tx = await tokenizer.createProposal(
"Increase licensing fees by 10%",
7200 // Voting period in blocks (~1 day)
);
// Vote on proposal
await tokenizer.castVote(proposalId, true); // Vote yes// Create royalty pool
await distributor.createRoyaltyPool(
tokenId,
[address1, address2, address3], // Beneficiaries
[5000, 3000, 2000] // Shares in basis points (50%, 30%, 20%)
);
// Send royalties
await distributor.receiveRoyalties(tokenId, { value: ethers.parseEther("10") });
// Beneficiaries withdraw
await distributor.withdrawRoyalties(tokenId);# Run all tests
forge test
# Run with verbosity
forge test -vvv
# Run specific test file
forge test --match-path test/AgriculturalIPNFT.t.sol
# Run with gas reporting
forge test --gas-report
# Run coverage
forge coverage
# Fuzz testing (configured for 10,000 runs)
forge test --fuzz-runs 10000The contracts are optimized for Kasplex L2 with:
- Compiler optimization: 200 runs
- Pull-based payments (vs push)
- Batch operations where possible
- Minimal storage usage
- Event-based data retrieval
- Access Control: Role-based permissions for sensitive operations
- Reentrancy Guards: Protection on all external calls
- Pausable: Emergency stop mechanism
- Upgradeable: UUPS proxy pattern for bug fixes
- Input Validation: Comprehensive checks on all parameters
- Safe Math: Solidity 0.8.22+ built-in overflow protection
After deployment, add your contract addresses here:
AgriculturalIPNFT: 0x...
RoyaltyDistributor: 0x...
IPTokenizer (Example): 0x...
KasplexSC/
βββ src/ # Smart contracts
β βββ AgriculturalIPNFT.sol
β βββ IPTokenizer.sol
β βββ RoyaltyDistributor.sol
βββ test/ # Test files
β βββ AgriculturalIPNFT.t.sol
β βββ Integration.t.sol
βββ script/ # Deployment scripts
β βββ Deploy.s.sol
βββ backend/ # Node.js backend
β βββ api/ # REST API routes
β βββ services/ # Event monitoring
β βββ utils/ # Utilities
βββ docs/ # Documentation
βββ foundry.toml # Foundry configuration
βββ package.json # Node.js dependencies
βββ README.md # This file
- Create contract in
src/ - Write tests in
test/ - Add deployment script in
script/ - Update backend event monitoring if needed
- Run tests and generate gas reports
- Deploy to testnet
- Update documentation
This is a testnet project. Contributions welcome!
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
MIT License - see LICENSE file for details
TESTNET ONLY: This code is deployed on Kasplex testnet for development and testing purposes. Do not use in production without a professional security audit.
- Issues: GitHub Issues
- Network: Kasplex Testnet
- Faucet: https://faucet.kasplextest.xyz/
- Explorer: https://frontend.kasplextest.xyz
- MoleculeDAO for IP-NFT inspiration
- OpenZeppelin for smart contract libraries
- Foundry for development framework
- Kasplex team for testnet infrastructure
Built with β€οΈ for agricultural innovation on Kasplex