Core Contract

SuperPiccellCore Contract

Overview

The SuperPiccellCore contract is a smart contract on the Ethereum blockchain that is designed to store various types of content in a decentralized manner. The content is categorized into six types: Character, Episode, Event, Item, Location, and Organization. Each piece of content has a unique ID and includes metadata such as encoding, content type, and revision. Please note that this is a prototype contract and is currently deployed on the Sepolia testnet, a development environment for Ethereum, and is subject to change in the future.

You can view the contract on the Sepolia testnet at the following links:

You can also interact with the contract using our Frontend Application (DApp) which is available at SuperPiccellCore DApp.

Frontend Application (DApp)

The frontend application (DApp) provides a user-friendly interface for interacting with the SuperPiccellCore contract. The DApp allows you to view all the contents stored in the contract in a more intuitive way compared to direct interaction with the blockchain. The DApp is built using the React JavaScript library and connects to the Ethereum blockchain using the ethers.js library.

To interact with the DApp, you will need a browser extension like MetaMask that allows your browser to connect to the Ethereum blockchain. Furthermore, you will need to switch your MetaMask network to the Sepolia network. You can add the Sepolia network to MetaMask by using chainlist or manually adding it from the settings menu.

Environment Requirements for the DApp

  • PC: MetaMask, Trust Wallet, Coinbase Wallet

  • Smartphone: MetaMask

Features

Function Name
Description

createContent

Creates new content. This function can only be called by the owner of the contract. Protected content or contract cannot be modified.

updateContent

pdates existing content. This function can only be called by the owner of the contract. It cannot update protected content.

deleteContent

Deletes content. This function can only be called by the owner of the contract. It cannot delete protected content.

getContent

Gets the content with the specified ID.

getAllContents

Gets all contents.

getContentsByContentType

Gets all contents that match the specified content type.

isContentProtected

Returns whether the content with the specified ID is protected or not.

Security Features

Function Name
Description

protectContract

Calling this function puts the contract into protection mode, preventing the creation, update, and deletion of content. This function can only be called by the owner of the contract.

protectContent

Marks specific content as protected, which prevents further updates or deletions of the content.

isContractProtected

Returns whether the contract is in protection mode.

Token Transfers

This contract can receive and send out Ether and ERC20 tokens. Token transfers can only be performed by the owner of the contract.

Function Name
Description

withdrawToken

Allows the owner to withdraw ERC20 tokens accidentally sent to the contract.

Data Structure of Contents

Each piece of content stored in the contract is represented as an instance of the Content struct. The Content struct has the following fields:

  • id (uint256): The unique identifier for the content. This ID is unique across all types of content.

  • exists (bool): A flag indicating whether the content exists. This is used internally by the contract.

  • encoding (string): The encoding of the content. Typically, this will be "UTF-8".

  • contentType (string): The type of the content. This could be one of "Character", "Episode", "Event", "Item", "Location", or "Organization".

  • content (string): This field contains the content data. The content is stored as a string. This string is a JSON string that encodes the content object.

  • revision (string): The revision of the content. This is typically set to "Genesis" when the content is first created.

  • createdAt (uint256): The timestamp (in seconds since the Unix epoch) when the content was created.

  • createdBy (address): The address of the user who created the content.

  • updatedAt (uint256): The timestamp (in seconds since the Unix epoch) when the content was last updated.

  • updatedBy (address): The address of the user who last updated the content.

You can retrieve the content with a specific ID by calling the getContent function and passing the ID as the argument.

Content Formats

In the SuperPiccellCore contract, the content field is a string that stores a JSON-encoded content object. The structure of the content object depends on the contentType. Here are the formats for each content type:

Character

Episode

Event

Item

Location

Organization

Last updated

Was this helpful?