Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test.js #31

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample Hardhat Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.js
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract DecentralizedSocialMedia {

struct Post {
address owner;
string content;
uint256 timestamp;
bool isDeleted;
}

mapping (uint256 => Post) public posts;
uint256 public postCount;

function createPost(string memory _content) public {
require(bytes(_content).length > 0, "Content cannot be empty");

postCount++;
posts[postCount] = Post(msg.sender, _content, block.timestamp, false);
}

function deletePost(uint256 _postId) public {
require(posts[_postId].owner == msg.sender, "Only the owner can delete the post");
require(!posts[_postId].isDeleted, "Post has already been deleted");

posts[_postId].isDeleted = true;
}

function getPost(uint256 _postId) public view returns (address, string memory, uint256) {
require(_postId <= postCount && _postId > 0, "Invalid post ID");

Post memory post = posts[_postId];
require(!post.isDeleted, "Post has been deleted");

return (post.owner, post.content, post.timestamp);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {defaultNetwork: 'buildbear',

networks: {
hardhat: {},
buildbear: {
url: "https://rpc.buildbear.io/Tough_Darth_Maul_b8516ccd",
},

},
solidity: {
compilers: [
{
version: '0.8.16',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: '0.8.4',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: '0.8.9',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: '0.5.0',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: '0.8.13',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: '0.5.5',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
},

etherscan: {
apiKey: {
buildbear: "test1",
},
customChains: [
{
network: "buildbear",
chainId: 8643,
urls: {
apiURL: "https://rpc.buildbear.io/verify/etherscan/Tough_Darth_Maul_b8516ccd",
browserURL: "https://explorer.buildbear.io/Tough_Darth_Maul_b8516ccd",
},
},
],
},
paths: {
sources: './contracts',
cache: './cache',
artifacts: './artifacts',
},
mocha: {
timeout: 20000000000,
},
};
Loading