Skip to content

Commit

Permalink
New contract and implementation of monetization in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
luloxi committed Oct 20, 2024
1 parent a92a104 commit 3f2211e
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 83 deletions.
271 changes: 271 additions & 0 deletions packages/foundry/broadcast/Deploy.s.sol/7615243/run-1729416339.json

Large diffs are not rendered by default.

146 changes: 73 additions & 73 deletions packages/foundry/broadcast/Deploy.s.sol/7615243/run-latest.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions packages/foundry/contracts/PunkSociety.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ contract PunkSociety is Ownable {

function createPost(
string memory _tokenURI
) public {
) public payable {
require(msg.value == 3 ether, "Must send 3 USDC to create a post");
uint256 postId = postIds++;
postIdToUser[postId] = msg.sender;
userPosts[msg.sender].push(postId);
Expand Down Expand Up @@ -133,7 +134,7 @@ contract PunkSociety is Ownable {
require(
!userToPostLikes[msg.sender][_postID], "You have already liked this post"
);
require(msg.value == 1 ether, "Must send 0.1 ETH to like a post");
require(msg.value == 1 ether, "Must send 1 USDC to like a post");

address postOwner = postIdToUser[_postID];
require(postOwner != address(0), "Post owner does not exist");
Expand All @@ -155,7 +156,7 @@ contract PunkSociety is Ownable {
require(
userToPostLikes[msg.sender][_postID], "You have not liked this post yet"
);
require(msg.value == 0.5 ether, "Must send 0.1 ETH to unlike a post");
require(msg.value == 0.5 ether, "Must send 0.5 USDC to unlike a post");

address postOwner = postIdToUser[_postID];
require(postOwner != address(0), "Post owner does not exist");
Expand Down
2 changes: 2 additions & 0 deletions packages/nextjs/app/create/_components/MintingButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from "react";
import { parseEther } from "viem";
import { useAccount } from "wagmi";
import { useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
import { uploadToPinata } from "~~/utils/pinata-upload";
Expand Down Expand Up @@ -52,6 +53,7 @@ export const MintingButtons: React.FC<MintingFormProps> = ({ yourJSON, resetForm
const contractResponse = await writeContractAsync({
functionName: "createPost",
args: [ipfsPath],
value: parseEther("3"),
});

if (contractResponse) {
Expand Down
3 changes: 3 additions & 0 deletions packages/nextjs/components/punk-society/LikedButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react";
import { parseEther } from "viem";
import { useAccount } from "wagmi";
import { useScaffoldReadContract, useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
import { notification } from "~~/utils/scaffold-eth";
Expand Down Expand Up @@ -41,6 +42,7 @@ const LikeButton: React.FC<LikeButtonProps> = ({ postId }) => {
await writeContractAsync({
functionName: "likePost",
args: [postId],
value: parseEther("1"),
});
notification.success("Liked successfully!");
} catch (error) {
Expand All @@ -58,6 +60,7 @@ const LikeButton: React.FC<LikeButtonProps> = ({ postId }) => {
await writeContractAsync({
functionName: "unlikePost",
args: [postId],
value: parseEther("0.5"),
});
notification.success("Unliked successfully!");
} catch (error) {
Expand Down
14 changes: 7 additions & 7 deletions packages/nextjs/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ const deployedContracts = {
},
],
outputs: [],
stateMutability: "nonpayable",
stateMutability: "payable",
},
{
type: "function",
Expand Down Expand Up @@ -1675,7 +1675,7 @@ const deployedContracts = {
},
7615243: {
PunkPosts: {
address: "0xDbDa30ad00b67702BDCEd019C3b46D35DB9e94ce",
address: "0x93c9699B00BE288c23AC9aD924769fA0C7B8D5A9",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -2360,7 +2360,7 @@ const deployedContracts = {
},
},
PunkProfile: {
address: "0x4359190563c0F38C84037a28288E01A2b1011Ec8",
address: "0xccf9D57d9a0468829D6DdC9bE54538b89a37a6da",
abi: [
{
type: "function",
Expand Down Expand Up @@ -2522,7 +2522,7 @@ const deployedContracts = {
inheritedFunctions: {},
},
PunkSociety: {
address: "0x5F909f607A29156Dd9Fc43382d09420bba7799A6",
address: "0xe45eFf7a6889893E166a0Dd84bfAa95ad9d04D64",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -2569,7 +2569,7 @@ const deployedContracts = {
},
],
outputs: [],
stateMutability: "nonpayable",
stateMutability: "payable",
},
{
type: "function",
Expand Down Expand Up @@ -3341,7 +3341,7 @@ const deployedContracts = {
},
},
SimpleFaucet: {
address: "0x1A44477AF531Ab811cd82772477f40750e763ff9",
address: "0x519f46ae0962abe5BF3516B225c3181914A3F735",
abi: [
{
type: "receive",
Expand Down Expand Up @@ -4311,7 +4311,7 @@ const deployedContracts = {
},
],
outputs: [],
stateMutability: "nonpayable",
stateMutability: "payable",
},
{
type: "function",
Expand Down

0 comments on commit 3f2211e

Please sign in to comment.