Gaming Asset Ownership Contract
What it does:
Allows players to register, trade, and manage ownership of in-game assets and NFTs securely on-chain, ensuring verifiable ownership and transferable assets.
Why it matters:
Prevents cheating, ensures transparency in asset ownership, enables real-world value for digital items, and allows automatic revenue sharing for creators or developers.
How it works:
-
Players register in-game items as tokenized assets (NFTs or ERC20/721)
-
Smart contracts manage ownership transfers, trading, and royalties
-
Developers or creators can receive automated revenue shares on secondary sales
-
Integrates with Gaming Marketplaces, Creator Collaboration Revenue Split, or NFT Tickets
-
Dashboards show owned items, trade history, and asset provenance
-
Supports in-game asset verification for authenticity and rarity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title GamingAssetOwnership
* @author Nam
* @notice Manages in-game asset ownership, transfers, and royalties on-chain
*/
contract GamingAssetOwnership is ERC721, Ownable {
struct Asset {
string metadataURI;
address creator;
uint256 royaltyPercent; // e.g., 5 for 5%
}
mapping(uint256 => Asset) public assets;
uint256 public assetCount;
// -------------------- EVENTS --------------------
event AssetMinted(uint256 indexed assetId, address owner, string metadataURI, uint256 royaltyPercent);
event AssetTransferred(uint256 indexed assetId, address from, address to, uint256 salePrice, uint256 royaltyPaid);
// -------------------- CONSTRUCTOR --------------------
constructor() ERC721("GameAsset", "GAST") {}
// -------------------- ASSET MANAGEMENT --------------------
function mintAsset(string calldata _metadataURI, uint256 _royaltyPercent) external {
require(_royaltyPercent 0) {
payable(a.creator).transfer(royaltyAmount);
}
// Transfer remaining to seller
payable(msg.sender).transfer(sellerAmount);
// Transfer NFT
_safeTransfer(msg.sender, _to, _assetId, "");
emit AssetTransferred(_assetId, msg.sender, _to, _salePrice, royaltyAmount);
}
// -------------------- VIEW FUNCTIONS --------------------
function getAsset(uint256 _assetId) external view returns (Asset memory) {
return assets[_assetId];
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
return assets[tokenId].metadataURI;
}
}