From d4c84a09317a084a80648555575329171fdb6503 Mon Sep 17 00:00:00 2001 From: Lynndabel Date: Thu, 25 Sep 2025 13:05:44 +0100 Subject: [PATCH 1/6] done --- README.md | 511 +++++++++++++----- {.cargo => Stylus/.cargo}/config.toml | 0 .env.example => Stylus/.env.example | 0 .gitignore => Stylus/.gitignore | 0 Cargo.lock => Stylus/Cargo.lock | 0 Cargo.toml => Stylus/Cargo.toml | 0 Stylus/README.md | 214 ++++++++ {examples => Stylus/examples}/counter.rs | 0 header.png => Stylus/header.png | Bin {licenses => Stylus/licenses}/Apache-2.0 | 0 {licenses => Stylus/licenses}/COPYRIGHT.md | 0 {licenses => Stylus/licenses}/DCO.txt | 0 {licenses => Stylus/licenses}/MIT | 0 .../rust-toolchain.toml | 0 {src => Stylus/src}/lib.rs | 0 {src => Stylus/src}/main.rs | 0 16 files changed, 589 insertions(+), 136 deletions(-) rename {.cargo => Stylus/.cargo}/config.toml (100%) rename .env.example => Stylus/.env.example (100%) rename .gitignore => Stylus/.gitignore (100%) rename Cargo.lock => Stylus/Cargo.lock (100%) rename Cargo.toml => Stylus/Cargo.toml (100%) create mode 100644 Stylus/README.md rename {examples => Stylus/examples}/counter.rs (100%) rename header.png => Stylus/header.png (100%) rename {licenses => Stylus/licenses}/Apache-2.0 (100%) rename {licenses => Stylus/licenses}/COPYRIGHT.md (100%) rename {licenses => Stylus/licenses}/DCO.txt (100%) rename {licenses => Stylus/licenses}/MIT (100%) rename rust-toolchain.toml => Stylus/rust-toolchain.toml (100%) rename {src => Stylus/src}/lib.rs (100%) rename {src => Stylus/src}/main.rs (100%) diff --git a/README.md b/README.md index 4620934..7fce05d 100644 --- a/README.md +++ b/README.md @@ -1,214 +1,453 @@ -![Image](./header.png) +# β˜• Gyfted -# Stylus Hello World +**Decentralized Creator Support Platform - Powered by Stylus** -Project starter template for writing Arbitrum Stylus programs in Rust using the [stylus-sdk](https://github.com/OffchainLabs/stylus-sdk-rs). It includes a Rust implementation of a basic counter Ethereum smart contract: +Gyfted is a revolutionary Web3 platform that enables creators to receive cryptocurrency tips from their supporters through a unified, gas-efficient smart contract system. Built on Arbitrum using the Stylus SDK, Gyfted provides a seamless tipping experience for content creators, developers, artists, and anyone building in the digital space. -```js -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; +## 🌟 Features -contract Counter { - uint256 public number; +### For Creators +- **πŸ†“ Free Registration** - No contract deployment costs +- **πŸ‘€ Rich Profiles** - Name, bio, avatar, and custom links +- **πŸ’° Direct Tips** - Receive ETH directly from supporters +- **πŸ“Š Analytics Dashboard** - Track tips, supporter count, and earnings +- **πŸ” Self-Custody** - Withdraw your tips anytime to your wallet +- **🌐 Discoverability** - Get found by new supporters - function setNumber(uint256 newNumber) public { - number = newNumber; - } +### For Supporters +- **🎯 Easy Tipping** - Send ETH with personalized messages +- **πŸ” Creator Discovery** - Browse and discover new creators +- **πŸ’¬ Message Support** - Send encouragement with your tips +- **⚑ Low Gas Fees** - Efficient Stylus smart contracts +- **πŸ”— Web3 Native** - Connect any Ethereum-compatible wallet - function increment() public { - number++; - } -} -``` +### For the Platform +- **🏭 Factory Pattern** - One contract serves all creators +- **πŸ’Ό Revenue Model** - Optional platform fees (2.5% default) +- **πŸ› οΈ Upgradeable** - Modular architecture for improvements +- **πŸ“ˆ Analytics** - Platform-wide statistics and insights -To set up more minimal example that still uses the Stylus SDK, use `cargo stylus new --minimal ` under [OffchainLabs/cargo-stylus](https://github.com/OffchainLabs/cargo-stylus). +## πŸ—οΈ Architecture -## Quick Start +Gyfted uses a factory contract pattern where a single smart contract manages multiple creators: -Install [Rust](https://www.rust-lang.org/tools/install), and then install the Stylus CLI tool with Cargo - -```bash -cargo install --force cargo-stylus cargo-stylus-check ``` - -Add the `wasm32-unknown-unknown` build target to your Rust compiler: - +Gyfted Factory Contract +β”œβ”€β”€ Creator Registry (profiles, balances) +β”œβ”€β”€ Tip Processing (with optional platform fees) +β”œβ”€β”€ Withdrawal System (creator-specific balances) +└── Discovery System (public creator listings) ``` -rustup target add wasm32-unknown-unknown + +**Key Components:** +- **Factory Contract**: Main contract managing all creators +- **Creator Profiles**: On-chain metadata (name, bio, avatar) +- **Tip Balances**: Individual creator balances +- **Event System**: Real-time tip notifications +- **Fee Management**: Optional platform sustainability model + +## πŸš€ Quick Start + +### Prerequisites + +- [Rust](https://rustup.rs/) (latest stable) +- [Cargo Stylus](https://docs.arbitrum.io/stylus/cargo-stylus) +- [Node.js](https://nodejs.org/) v18+ (for frontend) +- An Arbitrum testnet wallet with ETH + +### Installation + +1. **Clone the repository** + ```bash + git clone https://github.com/your-username/gyfted.git + cd gyfted + ``` + +2. **Install Stylus toolchain** + ```bash + cargo install cargo-stylus + ``` + +3. **Build the contract** + ```bash + cargo build --release --target wasm32-unknown-unknown + ``` + +4. **Deploy to Arbitrum Sepolia** + ```bash + cargo stylus deploy \ + --private-key="your-private-key" \ + --endpoint="https://sepolia-rollup.arbitrum.io/rpc" + ``` + +5. **Export ABI for frontend integration** + ```bash + cargo stylus export-abi + ``` + +### Smart Contract Usage + +#### For Creators + +**Register as a creator:** +```rust +// Call this function to join Gyfted +register_creator( + name: "Alice Developer", + bio: "Full-stack developer building Web3 tools", + avatar_url: "https://example.com/alice.jpg" +) ``` -You should now have it available as a Cargo subcommand: +**Update your profile:** +```rust +update_profile( + name: "Alice | Rust Developer", + bio: "Building the future with Rust and Web3", + avatar_url: "https://newurl.com/alice.jpg" +) +``` -```bash -cargo stylus --help +**Withdraw your tips:** +```rust +withdraw_my_tips() // Sends all accumulated tips to your wallet ``` -Then, clone the template: +#### For Supporters -``` -git clone https://github.com/OffchainLabs/stylus-hello-world && cd stylus-hello-world +**Send a tip:** +```rust +tip_creator( + creator: "0x742d35Cc6Bf5432532532B4C9c47", + message: "Love your tutorials! Keep it up! πŸš€" +) // Send ETH with the transaction ``` -### Testnet Information +#### View Functions -All testnet information, including faucets and RPC endpoints can be found [here](https://docs.arbitrum.io/stylus/reference/testnet-information). +```rust +// Get creator profile +get_creator_profile(creator_address) -### ABI Export +// Check creator's tip balance +get_creator_balance(creator_address) -You can export the Solidity ABI for your program by using the `cargo stylus` tool as follows: +// Browse all creators +get_registered_creators() -```bash -cargo stylus export-abi +// Check platform fee +get_platform_fee() // Returns basis points (250 = 2.5%) ``` -which outputs: +## πŸ’» Frontend Integration + +### Web3 Setup + +```javascript +import { ethers } from 'ethers'; +import GiftedABI from './contracts/Gyfted.json'; + +// Connect to contract +const provider = new ethers.providers.Web3Provider(window.ethereum); +const contract = new ethers.Contract(contractAddress, GiftedABI, provider); + +// Send a tip +async function tipCreator(creatorAddress, message, amount) { + const signer = provider.getSigner(); + const contractWithSigner = contract.connect(signer); + + const tx = await contractWithSigner.tip_creator( + creatorAddress, + message, + { value: ethers.utils.parseEther(amount) } + ); + + return await tx.wait(); +} -```js -/** - * This file was automatically generated by Stylus and represents a Rust program. - * For more information, please see [The Stylus SDK](https://github.com/OffchainLabs/stylus-sdk-rs). - */ +// Listen for tip events +contract.on("TipSent", (supporter, creator, amount, message) => { + console.log(`${supporter} tipped ${creator}: ${message}`); +}); +``` -// SPDX-License-Identifier: MIT-OR-APACHE-2.0 -pragma solidity ^0.8.23; +### React Component Example -interface ICounter { - function number() external view returns (uint256); +```jsx +import { useState, useEffect } from 'react'; - function setNumber(uint256 new_number) external; +function CreatorProfile({ creatorAddress }) { + const [profile, setProfile] = useState(null); + const [tipAmount, setTipAmount] = useState('0.001'); + const [message, setMessage] = useState(''); - function mulNumber(uint256 new_number) external; + useEffect(() => { + loadCreatorProfile(); + }, [creatorAddress]); - function addNumber(uint256 new_number) external; + const loadCreatorProfile = async () => { + const profileData = await contract.get_creator_profile(creatorAddress); + setProfile(profileData); + }; - function increment() external; + const sendTip = async () => { + try { + await tipCreator(creatorAddress, message, tipAmount); + alert('Tip sent successfully!'); + setMessage(''); + } catch (error) { + alert('Error sending tip: ' + error.message); + } + }; + + return ( +
+ {profile?.name} +

{profile?.name}

+

{profile?.bio}

+ +
+ setTipAmount(e.target.value)} + step="0.001" + min="0.001" + placeholder="Amount in ETH" + /> +