IP Protection Tool: Smart Contracts for IP Protection
1.1 IP Protection Tool Overview
1.2 Key Smart Contract Features for IP Tracking
1.3 Smart Contract
IPProtection.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract IPProtection {
struct Asset {
address creator;
string metadataURI; // IPFS hash or other identifier
uint256 timestamp;
address currentOwner;
}
mapping(uint256 => Asset) public assets;
uint256 public assetCount;
event AssetRegistered(uint256 assetId, address indexed creator, string metadataURI, uint256 timestamp);
event OwnershipTransferred(uint256 assetId, address indexed previousOwner, address indexed newOwner);
modifier onlyOwner(uint256 assetId) {
require(assets[assetId].currentOwner == msg.sender, "Caller is not the current owner");
_;
}
// Register a new asset
function registerAsset(string memory metadataURI) public returns (uint256) {
assetCount++;
uint256 assetId = assetCount;
assets[assetId] = Asset({
creator: msg.sender,
metadataURI: metadataURI,
timestamp: block.timestamp,
currentOwner: msg.sender
});
emit AssetRegistered(assetId, msg.sender, metadataURI, block.timestamp);
return assetId;
}
// View ownership and metadata of an asset
function getAssetDetails(uint256 assetId) public view returns (address, string memory, uint256, address) {
Asset memory asset = assets[assetId];
return (asset.creator, asset.metadataURI, asset.timestamp, asset.currentOwner);
}
// Transfer ownership of an asset to another address
function transferOwnership(uint256 assetId, address newOwner) public onlyOwner(assetId) {
address previousOwner = assets[assetId].currentOwner;
assets[assetId].currentOwner = newOwner;
emit OwnershipTransferred(assetId, previousOwner, newOwner);
}
}1.4 Usage and Deployment
Registering an Asset
Transferring Ownership
Viewing Asset Information
1.5 Best Practices and Security Considerations
Last updated
