I have written a simple blog post contract in solidity.
contract Blog {
uint256 counter ;
struct BlogPost {
uint256 id;
string title;
string content;
address user;
}
BlogPost[] public posts;
function createPost(string calldata _title, string calldata _content) external {
counter+=1;
BlogPost memory newPost;
newPost.id=counter;
newPost.title=_title;
newPost.content=_content;
newPost.user=msg.sender;
posts.push(newPost);
}
}
I have deployed my contract on a localnode. I have a few questions on what's happening here:
- When I deploy the contract, how and what is getting stored on the blockchain?
- When I call the createPost() function, where is the array of structs(BlogPost struct) getting stored on the blockchain? Is it stored on a single block or shared between mulitple blocks?
- When I call the createPost() function, what happens on the blockchain?