🎁Campaign Management

7H offers a robust API for managing interactive campaigns, providing users with engaging opportunities to participate and win exciting prizes. This API is designed to enhance user interaction and facilitate the distribution of rewards through various campaign types.

Use Cases

  1. Prize Draws for Web3 Projects:

    • Description: Web3 projects can utilize 7H's Prize Draws API to organize captivating events. Participants purchase tickets using their SPL tokens for a chance to win exclusive digital collectibles like NFTs.

  2. Event Ticketing with NFTs:

    • Description: Event organizers can leverage the Prize Draws API to distribute tickets for VIP passes, backstage access, or premium seating, all represented as NFTs.

  3. E-commerce Platform Promotions:

    • Description: Online shopping platforms can introduce prize draws as special promotional events. Users stand a chance to win exclusive merchandise, limited-time discounts, or even a shopping spree, all presented as NFTs.

import requests

class PrizeDrawsAPI: def init(self, base_url, api_key): self.base_url = base_url self.api_key = api_key

def create_prize_draw(self, ticket_asset_id, prize_asset_type, prize_asset_id, prize_asset_quantity,
                      ticket_price, max_tickets_per_user, total_tickets, number_of_winners_to_draw):
    headers = {
        'Authorization': f'Bearer {self.api_key}',
        'accept': 'application/json',
        'content-type': 'application/json',
    }

    data = {
        'ticket_asset_id': ticket_asset_id,
        'prize_asset_type': prize_asset_type,
        'prize_asset_id': prize_asset_id,
        'prize_asset_quantity': prize_asset_quantity,
        'ticket_price': ticket_price,
        'max_tickets_per_user': max_tickets_per_user,
        'total_tickets': total_tickets,
        'number_of_winners_to_draw': number_of_winners_to_draw,
    }

    response = requests.post(f'{self.base_url}/alpha/prize-draw', headers=headers, json=data)
    return response.json()

def purchase_tickets(self, prize_draw_id, email, amount):
    headers = {
        'Authorization': f'Bearer {self.api_key}',
        'accept': 'application/json',
        'content-type': 'application/json',
    }

    data = {
        'email': email,
        'amount': amount,
    }

    response = requests.post(f'{self.base_url}/alpha/prize-draw/{prize_draw_id}/ticket', headers=headers, json=data)
    return response.json()

def complete_prize_draw(self, prize_draw_id):
    headers = {
        'Authorization': f'Bearer {self.api_key}',
        'accept': 'application/json',
    }

    response = requests.post(f'{self.base_url}/alpha/prize-draw/{prize_draw_id}/complete', headers=headers)
    return response.json()

def settle_prize_draw(self, prize_draw_id):
    headers = {
        'Authorization': f'Bearer {self.api_key}',
        'accept': 'application/json',
    }

    response = requests.post(f'{self.base_url}/alpha/prize-draw/{prize_draw_id}/settle', headers=headers)
    return response.json()

def get_prize_draw_status(self, prize_draw_id):
    headers = {
        'Authorization': f'Bearer {self.api_key}',
        'accept': 'application/json',
    }

    response = requests.get(f'{self.base_url}/alpha/prize-draw/{prize_draw_id}', headers=headers)
    return response.json()

Workflow Overview

  1. Prize Draw Creation:

    • Endpoint: /sevenheaven/campaign/create

    • Description: As a campaign organizer, you can create a prize draw by specifying parameters such as ticket price, total tickets available, and the number of winners to be drawn. The API response includes essential details about the created prize draw.

  2. Ticket Sales:

    • Endpoint: /sevenheaven/campaign/sell-tickets

    • Description: Participants can purchase tickets using their SPL tokens. The sevenheaven platform manages ticket sales, ensuring adherence to limits such as the maximum number of tickets per user.

  3. Prize Drawing:

    • Endpoint: /sevenheaven/campaign/draw

    • Description: After the purchase period ends, the prize draw is completed, and a predetermined number of winners are selected from the pool of participating tickets. Winners are automatically awarded their prizes.

Prize Draw API Endpoints

Campaign Management

  • Create Campaign:

    • Endpoint: /sevenheaven/campaign/create

    • Description: Create a new campaign with specified parameters, including SPL token details.

  • Sell Tickets:

    • Endpoint: /sevenheaven/campaign/sell-tickets

    • Description: Enable users to purchase tickets by providing the campaign ID, user email, and the number of tickets they want to buy.

  • Complete Campaign:

    • Endpoint: /sevenheaven/campaign/complete

    • Description: Finalize the campaign to stop ticket sales. If auto-settle is enabled, the campaign will automatically move to the settling phase.

Ticket Management

  • Purchase Tickets:

    • Endpoint: /sevenheaven/campaign/purchase-tickets

    • Description: Allow users to buy tickets for a specific campaign by providing their email and the desired number of tickets.

  • Get Ticket Details:

    • Endpoint: /sevenheaven/campaign/ticket-details

    • Description: Retrieve detailed information about a specific ticket within a campaign using its unique identifier.

Campaign State Transitions

Pause, Resume, Cancel, Complete, Settle

  • Pause Campaign:

    • Endpoint: /sevenheaven/campaign/pause

    • Description: Temporarily halt a campaign, preventing further actions until resumed.

  • Resume Campaign:

    • Endpoint: /sevenheaven/campaign/resume

    • Description: Reactivate a paused campaign, allowing further actions.

  • Cancel Campaign:

    • Endpoint: /sevenheaven/campaign/cancel

    • Description: Permanently terminate a campaign. Cannot be resumed from this state.

  • Complete Campaign:

    • Endpoint: /sevenheaven/campaign/complete

    • Description: Finalize a campaign, marking it as completed. If auto-settle is true, it moves to the settling phase automatically.

  • Settle Campaign:

    • Endpoint: /sevenheaven/campaign/settle

    • Description: Settle a campaign by picking winners and distributing prizes. Async endpoint.

Ticket State Management

  • Get Ticket Status:

    • Endpoint: /sevenheaven/campaign/ticket-status

    • Description: Retrieve the status of a specific ticket within a campaign.

Requirements

  • SPLToken:

    • Create an SPL token for the campaign.

API Base URL

  • Base URL: https://api.7777.wtf/alpha/prize-draws

Additional Notes

  • Use start and end dates to control when a campaign starts and ends.

  • Disable auto-settling for more granular control over prize distribution.

This comprehensive API allows for seamless management of 7H campaigns, ensuring a dynamic and engaging experience for users participating in various prize draw scenarios.

Last updated