Skip to content

kchain-solutions/solidity-simple-blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple blog

The project aims to create a streamlined system for managing a blogging platform through the use of smart contracts. Users can create one or multiple blogs using the BlogFactory. They can then publish Posts, each of which is represented as a unique NFT that can be traded among users. The contents of each post are stored in a JSON file on IPFS and linked to the NFT.

BlogFactory.sol

The BlogFactory provides access to the newBlog method, which allows the calling user to instantiate a Blog smart contract. This method can be invoked multiple times by each user. Additionally, the getBlogs method returns an array of blogs associated with a specific address provided as input.

Events

  • event NewBlog(address owner, address blogAddr);

Blog.sol

The following is a list of methods provided by the Blog contract:

  • setBlogMetadata: used to set various metadata such as the title and image of the blog.
  • newPost: creates a new post, including its name, symbol, and a URI link to the IPFS resource that stores the content.
  • getPosts: retrieves an array of all posts belonging to the blog.
  • transferPost: transfers ownership of a specified post.
  • addPost: adds a post to your collection after it has been transferred to you.*

Events

  • event NewPost(address owner, address post, string URI);
  • event TransferPost(address oldOwner, address newOwner, address post);
  • event NewBlogMetadata(address blog, string URI);

Post.sol

The Post contract represents a post as a unique NFT entity.

Events

  • event ContentEdited(address post, address from, string URI);
  • event ChangePostOwner(address post, address oldOwner, address newOwner);

TheGraph

The contract was used to index content using TheGraph. Here is the link to the dedicated repository TheGraph simple blog repository

Example addresses (Goerli)

Hardhat command

Try running some of the following tasks:

npx hardhat help
npx hardhat test
npx hardhat run scripts/deploy.js

To deploy your own contracts you should create a .env file with the wallet mnemonic passphrase and endpoint to the nodes

MNEMONIC=mnemonic here
MUMBAI_ENDPOINT=https://polygon-mumbai.infura.io/v3/
GOERLI_ENDPOINT=https://goerli.infura.io/v3/
ETHERSCAN_API_KEY=

All these environment variables are importend into the hardhat.config.js file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published