Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Loading...
Loading
Loading...
Loading
Loading...
Loading
Contract Name:
PostManager
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
/**
* @title PostManager
* @dev Contract for managing blog posts on-chain
* @notice This contract stores IPFS/Bundlr CIDs and author addresses for blog posts
*/
contract PostManager {
/// @notice Auto-increment primary key for posts
uint256 public postCount;
/// @notice Mapping from post ID to IPFS/Bundlr CID
mapping(uint256 => string) public posts;
/// @notice Mapping from post ID to author address
mapping(uint256 => address) public authors;
/// @notice Event emitted when a new post is created
event PostCreated(uint256 indexed id, address indexed author, string cid);
/**
* @dev Creates a new post with the given CID
* @param cid The IPFS/Bundlr CID of the post content
* @return postId The ID of the created post
*/
function createPost(string calldata cid) external returns (uint256 postId) {
// Increment post count to get new post ID
postCount++;
postId = postCount;
// Store the post data
posts[postId] = cid;
authors[postId] = msg.sender;
// Emit event
emit PostCreated(postId, msg.sender, cid);
}
/**
* @dev Returns the post CID for a given post ID
* @param postId The post ID to query
* @return cid The IPFS/Bundlr CID of the post
*/
function getPost(uint256 postId) external view returns (string memory cid) {
return posts[postId];
}
/**
* @dev Returns the author address for a given post ID
* @param postId The post ID to query
* @return author The address of the post author
*/
function getAuthor(uint256 postId) external view returns (address author) {
return authors[postId];
}
/**
* @dev Returns the post data for a given post ID
* @param postId The post ID to query
* @return cid The IPFS/Bundlr CID of the post
* @return author The address of the post author
*/
function getPostData(uint256 postId) external view returns (string memory cid, address author) {
return (posts[postId], authors[postId]);
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"author","type":"address"},{"indexed":false,"internalType":"string","name":"cid","type":"string"}],"name":"PostCreated","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"authors","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"cid","type":"string"}],"name":"createPost","outputs":[{"internalType":"uint256","name":"postId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"postId","type":"uint256"}],"name":"getAuthor","outputs":[{"internalType":"address","name":"author","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"postId","type":"uint256"}],"name":"getPost","outputs":[{"internalType":"string","name":"cid","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"postId","type":"uint256"}],"name":"getPostData","outputs":[{"internalType":"string","name":"cid","type":"string"},{"internalType":"address","name":"author","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"postCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"posts","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60808060405234601557610500908161001b8239f35b600080fdfe6080604052600436101561001257600080fd5b60003560e01c80630b1e7f831461032c57806317906c2e146103705780633db804da1461029457806340731c241461032c5780634f8f0256146102c85780639e2b8488146102945763c7303c611461006957600080fd5b3461028f57602036600319011261028f5760043567ffffffffffffffff811161028f573660238201121561028f57806004013567ffffffffffffffff811161028f57366024828401011161028f57600054600019811461027957600101908160005581600052600160205260406000206000936100e6825461038e565b601f8111610234575b508390856020969385601f81116001146101a7577f8e40a51278abe2f4b410c0a96ff0bdd024b22666ca334062bf72afd596984bd694958391610199575b508660011b906000198860031b1c19161790555b8381526002875260408120336bffffffffffffffffffffffff60a01b82541617905584602460405193898552828a860152016040840137604085830101526040813395601f80199101168101030190a3604051908152f35b60249150840101353861012d565b8183528883209095601f198716845b8181106102145750967f8e40a51278abe2f4b410c0a96ff0bdd024b22666ca334062bf72afd596984bd69697106101f7575b5050600186811b019055610141565b840160240135600019600389901b60f8161c1916905538806101e8565b8287016024013584558998508a9750600190930192918b01918b016101b6565b82865260208620601f850160051c8101916020861061026f575b601f0160051c01905b81811061026457506100ef565b868155600101610257565b909150819061024e565b634e487b7160e01b600052601160045260246000fd5b600080fd5b3461028f57602036600319011261028f576004356000526002602052602060018060a01b0360406000205416604051908152f35b3461028f57602036600319011261028f57610322600435806000526001602052604060002090600052600260205261030d60018060a01b0360406000205416916103c8565b90604051928392604084526040840190610489565b9060208301520390f35b3461028f57602036600319011261028f57600435600052600160205261036c61035860406000206103c8565b604051918291602083526020830190610489565b0390f35b3461028f57600036600319011261028f576020600054604051908152f35b90600182811c921680156103be575b60208310146103a857565b634e487b7160e01b600052602260045260246000fd5b91607f169161039d565b90604051916000908054906103dc8261038e565b808652916001811690811561046b5750600114610430575b5050829003601f01601f1916820167ffffffffffffffff81118382101761041a57604052565b634e487b7160e01b600052604160045260246000fd5b90915060005260206000206000905b82821061045557506020915083010138806103f4565b600181602092548385890101520191019061043f565b9150506020925060ff191682850152151560051b83010138806103f4565b919082519283825260005b8481106104b5575050826000602080949584010152601f8019910116010190565b8060208092840101518282860101520161049456fea264697066735822122060681481a65486104fad9ce077bc4446c0ef97fca2cceca38448b557fa3c17d264736f6c634300081c0033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c80630b1e7f831461032c57806317906c2e146103705780633db804da1461029457806340731c241461032c5780634f8f0256146102c85780639e2b8488146102945763c7303c611461006957600080fd5b3461028f57602036600319011261028f5760043567ffffffffffffffff811161028f573660238201121561028f57806004013567ffffffffffffffff811161028f57366024828401011161028f57600054600019811461027957600101908160005581600052600160205260406000206000936100e6825461038e565b601f8111610234575b508390856020969385601f81116001146101a7577f8e40a51278abe2f4b410c0a96ff0bdd024b22666ca334062bf72afd596984bd694958391610199575b508660011b906000198860031b1c19161790555b8381526002875260408120336bffffffffffffffffffffffff60a01b82541617905584602460405193898552828a860152016040840137604085830101526040813395601f80199101168101030190a3604051908152f35b60249150840101353861012d565b8183528883209095601f198716845b8181106102145750967f8e40a51278abe2f4b410c0a96ff0bdd024b22666ca334062bf72afd596984bd69697106101f7575b5050600186811b019055610141565b840160240135600019600389901b60f8161c1916905538806101e8565b8287016024013584558998508a9750600190930192918b01918b016101b6565b82865260208620601f850160051c8101916020861061026f575b601f0160051c01905b81811061026457506100ef565b868155600101610257565b909150819061024e565b634e487b7160e01b600052601160045260246000fd5b600080fd5b3461028f57602036600319011261028f576004356000526002602052602060018060a01b0360406000205416604051908152f35b3461028f57602036600319011261028f57610322600435806000526001602052604060002090600052600260205261030d60018060a01b0360406000205416916103c8565b90604051928392604084526040840190610489565b9060208301520390f35b3461028f57602036600319011261028f57600435600052600160205261036c61035860406000206103c8565b604051918291602083526020830190610489565b0390f35b3461028f57600036600319011261028f576020600054604051908152f35b90600182811c921680156103be575b60208310146103a857565b634e487b7160e01b600052602260045260246000fd5b91607f169161039d565b90604051916000908054906103dc8261038e565b808652916001811690811561046b5750600114610430575b5050829003601f01601f1916820167ffffffffffffffff81118382101761041a57604052565b634e487b7160e01b600052604160045260246000fd5b90915060005260206000206000905b82821061045557506020915083010138806103f4565b600181602092548385890101520191019061043f565b9150506020925060ff191682850152151560051b83010138806103f4565b919082519283825260005b8481106104b5575050826000602080949584010152601f8019910116010190565b8060208092840101518282860101520161049456fea264697066735822122060681481a65486104fad9ce077bc4446c0ef97fca2cceca38448b557fa3c17d264736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.