🥷
Samurai Protocol
  • DISCLAIMER
  • Samurai Financial
  • 1. What is Samurai and how does it work ?
    • 1.1 - What is Samurai?
    • 1.2 - What is the total supply of HNR tokens ?
    • 1.3 - Now, how does it actually work ?
    • 1.4 - How does Samurai differ from RING?
    • 1.5 - Why is SAMURAI on the Fantom (FTM) ?
    • 1.6 - Is Metamask the only wallet compatible for now ? What about TrustWallet ?
    • 1.7 - Do I need to install a VPS?
    • 1.8 - Do I need to keep my computer running ?
    • 1.9 - Where can I see the size of the liquidity pool ?
    • 1.10 - Smart Contract Functionality
  • 2. Understanding the NODES
    • 2.1 How does the Lottery system work?
    • 2.2 How does sliding tax work?
    • 2.3 - How much does a node cost ?
    • 2.4 - Can nodes be transferred from one wallet to another ?
    • 2.5 - Are these real nodes ?
    • 2.6 - Why do you call these "nodes" ?
    • 2.7 - I don’t see my rewards every 4 or 8 hours. Is there a problem ?
    • 2.8 - What happens if I don't claim my rewards every time ?
  • Tokenomics
  • Governance
  • Samurai AI
  • Vaults
  • MultiChain ZenGarden
  • Levels
  • Sambot
  • ZenEstate
  • Governance Proposals
    • Samurai Governance
    • Initiate and adopt protocol level governance
    • SIP-1: Adopt and enforce an incentivised LP staking mechanism - Zen Garden
  • [EXTENSION] SIP-1: Adopt and enforce an incentivised LP staking mechanism - Zen Garden
  • SIP-2: Implement a Samurai native OTC NFT solution
  • [EXTENSION] SIP-2: Implement a Samurai native OTC NFT solution
  • SIP-3: Implement, adopt and enforce Samurai Vaults
  • SIP-4: Implement, adopt and enforce Samurai Multichain ZenGarden
  • SIP-5: Implement, adopt and enforce Samurai Levels
  • SIP-6: Replenish Samurai Levels rewards
  • SIP-7: Conduct an OTC NFT acquisition event
  • SIP-8: Retroactive funding
  • SIP-9: Expand MultiChain ZenGarden
  • SIP-10: Conduct an OTC NFT distribution event
  • SIP-11: Temporarily pause Samurai Levels
  • SIP-12: Replenish Samurai Node NFT's rewards
  • SIP-13: Levels v2 Product feature set Ideation
  • SIP-14: Deploy and fund Samurai Governance Vault
  • SIP-15: Implement, adopt and enforce Samurai Levels v2
  • SIP-16: Conduct ‘Settlement & Release’ initiative
  • SIP-17: Expand ‘Settlement & Release’ initiative
  • SIP-18: Implement, adopt and enforce an update to Samurai Node NFT RPC Endpoints
  • SIP-19: Implement, adopt and enforce Samurai Chat
  • SIP-20: Refine Samurai Levels Parameters and Conditions
  • SIP-21: Retroactive funding 2.0
  • SIP-22: Conduct an OTC NFT acquisition event
  • SIP-23: Conduct an OTC NFT distribution event
  • SIP-24: Enact a Samurai Governance Vault Conversion
  • SIP-25: Refine Samurai Chat Parameters
  • SIP-26: Replenish Samurai Levels v2 rewards
  • Articles / Announcements
    • Samurai is here!
    • Honour
    • News, updates, migration and plans for Honour
    • Clearing the air and moving onwards
    • The path towards sustainability
Powered by GitBook
On this page
  • Motivation
  • Specification
  • The proposed Solidity code / smart contracts

SIP-19: Implement, adopt and enforce Samurai Chat

Motivation

This proposal suggests for the protocol to adopt and enforce a set of smart contracts (specified below) that enable, facilitate and provide access to the subscription of a newly developed product called Samurai Chat. Samurai Chat represents a brand new SaaS (Software-as-a-Service) feature and solution that intends to transcend the conventional ChatGPT experience. The product introduces a suite of custom features, including a prompt library, history search, and folders.

Samurai Chat aligns with the protocol's mission to leverage cutting-edge technology and grow its ecosystem and suite of products. The proposal and the associated implementation of the Samurai Chat feature further attempts to ensure that the Samurai protocol remains at the forefront of decentralized AI solutions. The implementation of this proposal shall further bolster the utility of the Samurai Node NFTs and the xHNR token.

The feature shall be exclusively available to Samurai Node NFT holders and xHNR token holders.

Specification

The scope of the product comprises of the following elements.

  • Samurai Chat Interface

    • A newly developed frontend interface specifically designed for interaction with the OpenAI GPT model.

    • Tailored UI/UX to enhance user interaction and provide a seamless experience.

    • Incorporation of Samurai’s branding and design elements to maintain protocol identity.

  • Exclusive Access

    • Access to Samurai Chat shall be exclusively facilitated and provided to Samurai Node NFT holders and xHNR token holders. This would further reinforce the increasing token and NFT utility.

  • Custom Features

    • Prompt Library: A comprehensive collection of pre-designed and user-contributed prompts for diverse applications, ranging from simple queries to complex scenarios.

    • History Search: Allows users to search and filter through their previous interactions with the AI, providing a valuable tool for tracking conversations and retrieving information.

    • Folders: Enables users to categorize and store their interactions in an organized manner, facilitating efficient information management and retrieval.

  • API Key Requirement

    • Users shall supply their own OpenAI API keys, linking their use of Samurai Chat to their OpenAI account. This would ensure that each user's interaction is based on their specific OpenAI subscription, as well as it ensures the experience is personalized and secure.

  • Subscription Model

    • Enforce a monthly (28 days) subscription fee of 100,000 xHNR

    • To access the subscription, the user shall hold 100x Samurai Node NFTs

    • This fee structure shall balance accessibility with the premium nature of the service

    • The collected subscription fees shall be directed towards the protocol's treasury

Implementation Approach

  • Frontend Development

    • Development of a user-friendly interface with advanced and custom features.

  • Subscription Management

    • Creating a system to handle subscriptions, including sign-ups, and renewals

    • Implementation of smart contracts to manage the collection and allocation of subscription fees in xHNR tokens.

The proposal primarily pertains to the adoption of the smart contracts that would enable and facilitate the product’s subscription model, as its enforcement is enacted on-chain.

The proposed Solidity code / smart contracts

SamuraiSubscription.sol

// SPDX-License-Identifier: MIT pragma solidity 0.8.13;

import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/interfaces/IERC20.sol"; import "@openzeppelin/contracts/interfaces/IERC721Enumerable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "./IUniswapV2Router02.sol";

contract SamuraiSubscription is Ownable, Pausable { IERC20 public xhnr; IERC721Enumerable public hnrNodes; IUniswapV2Router02 public uniswapV2Router;

uint256 public threshold; uint256 public feeRate; uint256 public subscriptionCost;

mapping(address => uint256) public subscriptions;

using SafeMath for uint256;

constructor( address _xhnr, address _hnrNodes, address _uniswapV2Router, uint256 _threshold, uint256 _feeRate, uint256 _subscriptionCost ) { xhnr = IERC20(_xhnr); hnrNodes = IERC721Enumerable(_hnrNodes); uniswapV2Router = IUniswapV2Router02(_uniswapV2Router); threshold = _threshold; feeRate = _feeRate; subscriptionCost = _subscriptionCost; }

receive() external payable virtual { // }

function subscribe() external whenNotPaused { address sender = msg.sender; require(hnrNodes.balanceOf(sender) >= threshold, "Contract: not a holder!"); uint256 timeNow = block.timestamp; uint256 existingSubscription = subscriptions[sender]; require( timeNow > existingSubscription, "Contract: subscription already active!" ); // charge the subscription xhnr.transferFrom(sender, address(this), subscriptionCost); uint256 fee = subscriptionCost.mul(feeRate).div(100); // take the fee swapTokensForEth(fee); // 28 days in seconds uint256 oneMonth = 28 * 24 * 60 * 60; uint256 subscriptionEnd = timeNow + oneMonth;

subscriptions[sender] = subscriptionEnd;

}

function isSubscribed() external view returns (bool) { address sender = msg.sender; uint256 timeNow = block.timestamp; uint256 subscriptionEnd = subscriptions[sender];

return timeNow <= subscriptionEnd;

}

function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address; path[0] = address(xhnr); path[1] = uniswapV2Router.WETH();

xhnr.approve(address(uniswapV2Router), tokenAmount);

uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
  tokenAmount,
  0, // accept any amount of ETH
  path,
  address(this),
  block.timestamp
);

}

// owner related function setSubscriptionCost(uint256 _subscriptionCost) external onlyOwner { subscriptionCost = _subscriptionCost; }

function setThreshold(uint256 _threshold) external onlyOwner { threshold = _threshold; }

function setFeeRate(uint256 _feeRate) external onlyOwner { feeRate = _feeRate; }

function release() external onlyOwner { xhnr.transfer(owner(), xhnr.balanceOf(address(this))); }

function releaseNative() external onlyOwner { payable(owner()).transfer(address(this).balance); }

function pause(bool en) external onlyOwner { en ? _pause() : _unpause(); } }

PreviousSIP-18: Implement, adopt and enforce an update to Samurai Node NFT RPC EndpointsNextSIP-20: Refine Samurai Levels Parameters and Conditions

Last updated 5 months ago