Skip to content

Parallel-news/permacast-curator-contract

Repository files navigation

Spider Contract

Smart contract project for on-chain interaction functionalities of Permacast.

Contract Description

CuratorRegistry

Decentralized curator registry contract for recording users who activate their curator identity.

Main Functions:

  • activateCurator() - Activate curator identity (each address can be activated only once)
  • checkCurator(address) - Check whether an address is a curator
  • getTotalCurators() - Get the total number of curators
  • getCurators(offset, limit) - Get curator list with pagination

ContentInteraction

Content interaction contract for recording on-chain content boosts by users.

Main Functions:

  • boostContent(contentId, contentType) - Boost content
  • cancelBoost(contentId) - Cancel content boost
  • checkInteraction(user, contentId) - Check boost status
  • getUserInteractionCount(user) - Get the number of user interactions
  • getContentBoostCount(contentId) - Get the number of content boosts
  • getContentBoosters(contentId) - Get the list of users who boosted the content

Install Dependencies

pnpm install

Compile Contracts

pnpm compile

Run Tests

# Run all tests
pnpm test

# Run tests and show gas consumption
pnpm test:gas

Deploy Contracts

1. Configure Environment Variables

Copy .env.example to .env and fill in the required fields:

cp .env.example .env

Edit the .env file:

# Private key (used for contract deployment, do NOT include the 0x prefix)
PRIVATE_KEY=your_private_key_here

# BSC Mainnet RPC
BSC_RPC_URL=https://bsc-dataseed1.binance.org

# BSC Testnet RPC
BSC_TESTNET_RPC_URL=https://data-seed-prebsc-1-s1.binance.org:8545

# Whether to use testnet (true for testnet, false for mainnet)
USE_BSC_TESTNET=true

# BSCScan API Key (for contract verification)
BSCSCAN_API_KEY=your_bscscan_api_key_here

# Contract addresses (fill in after deployment)
CURATOR_REGISTRY_ADDRESS=
CONTENT_INTERACTION_ADDRESS=

Important Notes:

  • Set USE_BSC_TESTNET=true for development and testing
  • Set USE_BSC_TESTNET=false for production
  • Remember to fill in the contract addresses in .env after deployment

2. Deploy to Local Network

# Start local node
pnpm node

# Deploy in another terminal
pnpm deploy:local

3. Deploy to BSC Testnet

pnpm deploy:testnet

4. Deploy to BSC Mainnet

pnpm deploy:mainnet

Automatic Deployment Info Saving

The deployment script will automatically:

  1. Save deployment info to a JSON file

    • Path: deployments/{network}-{chainId}.json
    • Content: network info, deployer address, contract addresses, transaction hash, timestamp
  2. Auto-update the .env file

    • Auto-add/update CURATOR_REGISTRY_ADDRESS
    • Auto-add/update CONTENT_INTERACTION_ADDRESS
  3. Deployment Info Example

    {
      "network": "hardhat",
      "chainId": "31337",
      "deployer": "0x...",
      "timestamp": "2026-02-13T10:37:04.852Z",
      "contracts": {
        "CuratorRegistry": {
          "address": "0x...",
          "transactionHash": "0x..."
        },
        "ContentInteraction": {
          "address": "0x...",
          "transactionHash": "0x..."
        }
      }
    }

Verify Contracts

You can verify contracts on BSCScan after deployment:

# Testnet
pnpm verify:testnet <CONTRACT_ADDRESS>

# Mainnet
pnpm verify:mainnet <CONTRACT_ADDRESS>

Network Configurations

  • Hardhat Local: Chain ID 31337
  • BSC Testnet: Chain ID 97
  • BSC Mainnet: Chain ID 56

Contract Addresses

Deployed contract addresses will be saved in deployment logs. Please keep them properly.

Security Considerations

  1. Private Key Security: Never commit private keys to version control systems
  2. Sufficient Testing: Fully test on Testnet before deploying to Mainnet
  3. Gas Optimization: Contracts have been gas-optimized, but actual consumption should still be monitored
  4. Audit Recommendation: A security audit is recommended before Mainnet deployment

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors