Solidity Interfaces and ABIs

IGachapon

Interface

IGachapon.sol
pragma solidity ^0.8.6;

/// @title Interface implemented by all gachapons created by the GachaponControlTower
/// @author KirienzoEth for DokiDoki
interface IGachapon {
  /// @dev Undefined = Round doesn't exist, Pending = waiting for oracle response, Unclaimed = oracle answered, Completed = Prizes were withdrawn
  enum RoundStatus { Undefined, Pending, Unclaimed, Completed, Cancelled }
  
  struct Round {
    bytes32 id; // request id
    address player; // address of player
    RoundStatus status; // status of the round
    uint8 times; // how many times of this round
    uint256[10] prizes; // Prizes obtained in this round
  }
  
  struct Nft {
    address collection; // adress of the contract of the collection
    uint256 id; // token ID of the nft
    uint256 amount; // winnable amount left in the gachapon
  }

  /// @notice Get the state of a round
  function getRound(bytes32 _roundId) external returns (Round memory);
  /// @notice Get the token address of the currency used by this gachapon
  function currency() external returns (address);
  /// @notice Return the number of prizes that are still available
  function getRemaningPrizesAmount() external returns(uint256);
  /// @notice Get the nft at index `_index`
  function getNft(uint256 _index) external returns(Nft memory);
  /// @notice The number of different nfts in the gachapon
  /// @dev Use this to query `getNft` without going out of bounds, latest index is `nftsAmount() - 1`
  function nftsAmount() external view returns(uint256);
  
  /// @notice Play the gachapon `_times` times
  function play(uint8 _times) external;
  /// @notice Claim the prizes won in a round
  function claimPrizes(bytes32 _roundId) external;
  /// @notice Transferring ownership also change the artist's address
  function transferOwnership(address _newOwner) external;

  /// @dev Player paid and oracle was contacted, refer to getRound(_requestId) to check if the prizes were distributed or not
  event RoundStarted(bytes32 indexed _requestId, address indexed _player, uint8 _times);
  /// @dev Oracle answered and the drawn prizes were stored, numbers in _prizes are indexes of the variable 'nfts'
  event RoundCompleted(bytes32 indexed _requestId, address indexed _player, uint8 _times, uint256[10] _prizes);
  /// @dev Oracle didn't answer and an operator re-created a round for this player
  event RoundCancelled(bytes32 _requestId);
  /// @dev Stored prizes were sent to the user
  event PrizesClaimed(bytes32 indexed _requestId);
}

ABI

Last updated

Was this helpful?