Ajmal Adamz Research Files (Basics only)
Concise PoC descriptions and practical minimal proofs-of-concept. Select a topic below to view detailed material.
Overview
This page collects basic research files: Smart Contracts, Decentralized Finance, and Blockchain VM & Concepts with practical PoC examples and concise security notes.
RESEARCH Files
Quick Index
- Smart Contract: Core practices, ownership, safe patterns and minimal examples.
- DeFi: Simple lending pool & share model — deposit/withdraw maths and security notes.
- Blockchain VM & Concepts: Telemetry anchoring (IPFS + on-chain CID anchoring), verification and provenance notes for telemetry.
Smart Contracts — Basics & Best Practices (Overview & PoC)
Smart contracts are deterministic on-chain programs that manage state and enforce rules automatically. Focus on gas efficiency, strong access control, input validation, and safe interaction patterns.
Core concepts
- Minimize storage writes; prefer memory for temporary data.
- Explicit access control (owner/roles); protect admin functions.
- Prevent reentrancy: checks-effects-interactions; use ReentrancyGuard.
- Validate inputs: avoid zero values, check array bounds, validate addresses.
- Emit events for important state changes for off-chain indexing and audits.
Minimal Solidity PoC (Ownable + SafeDeposit)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleOwnable {
address public owner;
event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
constructor() { owner = msg.sender; }
modifier onlyOwner() { require(msg.sender == owner, "owner only"); _; }
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "zero");
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract SafeDeposit is SimpleOwnable {
mapping(address => uint) public balances;
event Deposited(address indexed who, uint amount);
function deposit() external payable {
require(msg.value > 0, "zero");
balances[msg.sender] += msg.value;
emit Deposited(msg.sender, msg.value);
}
function withdraw(uint amount) external {
require(balances[msg.sender] >= amount, "insufficient");
balances[msg.sender] -= amount;
(bool ok, ) = msg.sender.call{value: amount}("");
require(ok, "transfer failed");
}
}
Decentralized Election Voting — Vote Hash Anchoring (Proof of Concept)
Decentralized voting mechanisms aim to preserve voter privacy while providing verifiable, tamper-evident records. A common pattern: store salted vote hashes on-chain and reveal salts off-chain for verification.
Design summary
- Register eligible voter addresses (on-chain) or use cryptographic credentials off-chain.
- Voter computes salted vote-hash off-chain and submits only the hash on-chain.
- Contract records hash and marks address as voted; no plaintext choices stored on-chain.
- After poll close, organizer reveals salts/payloads off-chain; auditors verify hashes match stored entries.
Security & privacy notes
- Keep salts private until reveal; leaking salts breaks privacy.
- Consider commit-reveal delays and anti-front-running measures.
- For stronger privacy, use zk-proofs, blind signatures or mixnets.
- Protect admin actions with multisig/timelocks to avoid unauthorized changes.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract VoteHashAnchor {
address public admin;
mapping(address => bool) public registered;
mapping(bytes32 => bool) public voteSeen;
mapping(address => bool) public hasVoted;
bool public closed;
constructor() { admin = msg.sender; }
modifier onlyAdmin { require(msg.sender == admin, "admin only"); _; }
modifier open { require(!closed, "poll closed"); _; }
function registerVoter(address v) external onlyAdmin { registered[v] = true; }
function closePoll() external onlyAdmin { closed = true; }
// submit hash of (pollId || voterSalt || choice)
function submitVote(bytes32 h) external open {
require(registered[msg.sender], "not registered");
require(!hasVoted[msg.sender], "already voted");
require(!voteSeen[h], "duplicate vote");
voteSeen[h] = true;
hasVoted[msg.sender] = true;
}
}
Decentralized Finance — Simple Lending Pool & Share Model (Proof of Concept)
Summary: Depositors receive pool shares representing proportional ownership; withdrawals redeem shares for assets at current asset-per-share.
Model summary
- Initial depositor defines an initial share-to-asset ratio.
- Subsequent deposits mint shares proportional to existing totalAssets and totalShares.
- Withdrawals burn shares and transfer assets equal to shareAmount * totalAssets / totalShares.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 { function transferFrom(address from, address to, uint amount) external returns(bool); function transfer(address to, uint amount) external returns(bool); function balanceOf(address owner) external view returns(uint); }
contract SimpleLendingPool {
IERC20 public immutable token;
uint public totalShares;
uint public totalAssets;
mapping(address => uint) public shares;
constructor(address _token) { token = IERC20(_token); }
function deposit(uint amount) external {
require(amount>0, "zero");
uint minted;
if (totalShares == 0) {
minted = amount;
} else {
minted = amount * totalShares / totalAssets;
}
token.transferFrom(msg.sender, address(this), amount);
totalAssets += amount;
totalShares += minted;
shares[msg.sender] += minted;
}
function withdraw(uint shareAmount) external {
require(shareAmount>0 && shares[msg.sender]>=shareAmount, "invalid");
uint value = shareAmount * totalAssets / totalShares;
shares[msg.sender] -= shareAmount;
totalShares -= shareAmount;
totalAssets -= value;
token.transfer(msg.sender, value);
}
}
Blockchain Virtual Machine & Concepts — Telemetry Anchoring (IPFS + On-chain CID)
Goal: Upload large telemetry snapshots to IPFS and anchor CIDs on-chain to achieve tamper-evidence and verifiable provenance for telemetry data.
Flow summary
- Upload telemetry snapshot to IPFS and obtain CID.
- Submit CID, timestamp, and submitter to the on-chain anchor contract.
- Auditors fetch the CID from IPFS and verify snapshot integrity and provenance.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TelemetryAnchor {
struct Entry { string cid; uint256 ts; address submitter; }
Entry[] public entries;
event Anchored(uint indexed id, string cid, uint256 ts, address indexed submitter);
function anchorCID(string calldata cid) external {
entries.push( Entry({ cid: cid, ts: block.timestamp, submitter: msg.sender }) );
emit Anchored(entries.length-1, cid, block.timestamp, msg.sender);
}
function getEntry(uint id) external view returns(string memory, uint256, address) {
Entry storage e = entries[id];
return (e.cid, e.ts, e.submitter);
}
}
Blockchain For Space Research
Uses: decentralized provenance for telemetry, secure off-chain storage (IPFS) with on-chain anchors, distributed consensus for task scheduling, and audit trails for spacecraft telemetry and experiments. Combine lightweight on-board signing with periodic anchor uploads from ground-stations or relay nodes.
Example flow (high level)
- On-board system signs telemetry snapshot; snapshot uploaded to IPFS via a relay or ground station.
- Ground station submits CID to on-chain anchor contract (TelemetryAnchor PoC) with timestamp and attestation.
- Researchers verify CID and signature chain to confirm data provenance and integrity.
// pseudo-code (off-chain uploader)
// 1) sign snapshot, 2) upload to IPFS, 3) submit CID to TelemetryAnchor
// NOTE: this is illustrative; real integrations need secure key storage and relay nodes.
const signed = signSnapshot(privateKey, snapshot);
const cid = await ipfs.add(snapshot);
await telemetryAnchorContract.anchorCID(cid);
These files provide basic PoC material only. Production-grade, optimized, or proprietary details are intentionally omitted.