Skip to main content

TicketBooth

Git Source

Mainnet: 0xee2eBCcB7CDb34a8A822b589F9E8427C24351bfc

Inherits: TerminalUtility, Operatable, ITicketBooth

Manage Ticket printing, redemption, and account balances.

*Tickets can be either represented internally staked, or as unstaked ERC-20s. This contract manages these two representations and the conversion between the two.

The total supply of a project's tickets and the balance of each account are calculated in this contract.

State Variables

projects

The Projects contract which mints ERC-721's that represent project ownership and transfers.

IProjects public immutable override projects;

ticketsOf

mapping(uint256 => ITickets) public override ticketsOf;

stakedBalanceOf

mapping(address => mapping(uint256 => uint256)) public override stakedBalanceOf;

stakedTotalSupplyOf

mapping(uint256 => uint256) public override stakedTotalSupplyOf;

lockedBalanceOf

mapping(address => mapping(uint256 => uint256)) public override lockedBalanceOf;

lockedBalanceBy

mapping(address => mapping(address => mapping(uint256 => uint256))) public override lockedBalanceBy;

Functions

totalSupplyOf

The total supply of tickets for each project, including staked and unstaked tickets.

function totalSupplyOf(uint256 _projectId) external view override returns (uint256 supply);

Parameters

NameTypeDescription
_projectIduint256The ID of the project to get the total supply of.

Returns

NameTypeDescription
supplyuint256The total supply.

balanceOf

The total balance of tickets a holder has for a specified project, including staked and unstaked tickets.

function balanceOf(address _holder, uint256 _projectId) external view override returns (uint256 balance);

Parameters

NameTypeDescription
_holderaddressThe ticket holder to get a balance for.
_projectIduint256The project to get the _hodlers balance of.

Returns

NameTypeDescription
balanceuint256The balance.

constructor

constructor(IProjects _projects, IOperatorStore _operatorStore, ITerminalDirectory _terminalDirectory)
Operatable(_operatorStore)
TerminalUtility(_terminalDirectory);

Parameters

NameTypeDescription
_projectsIProjectsA Projects contract which mints ERC-721's that represent project ownership and transfers.
_operatorStoreIOperatorStoreA contract storing operator assignments.
_terminalDirectoryITerminalDirectoryA directory of a project's current Juicebox terminal to receive payments in.

issue

Issues an owner's ERC-20 Tickets that'll be used when unstaking tickets.

Deploys an owner's Ticket ERC-20 token contract.

function issue(uint256 _projectId, string calldata _name, string calldata _symbol)
external
override
requirePermission(projects.ownerOf(_projectId), _projectId, Operations.Issue);

Parameters

NameTypeDescription
_projectIduint256The ID of the project being issued tickets.
_namestringThe ERC-20's name. " Juicebox ticket" will be appended.
_symbolstringThe ERC-20's symbol. "j" will be prepended.

print

Print new tickets.

Only a project's current terminal can print its tickets.

function print(address _holder, uint256 _projectId, uint256 _amount, bool _preferUnstakedTickets)
external
override
onlyTerminal(_projectId);

Parameters

NameTypeDescription
_holderaddressThe address receiving the new tickets.
_projectIduint256The project to which the tickets belong.
_amountuint256The amount to print.
_preferUnstakedTicketsboolWhether ERC20's should be converted automatically if they have been issued.

redeem

Redeems tickets.

Only a project's current terminal can redeem its tickets.

function redeem(address _holder, uint256 _projectId, uint256 _amount, bool _preferUnstaked)
external
override
onlyTerminal(_projectId);

Parameters

NameTypeDescription
_holderaddressThe address that owns the tickets being redeemed.
_projectIduint256The ID of the project of the tickets being redeemed.
_amountuint256The amount of tickets being redeemed.
_preferUnstakedboolIf the preference is to redeem tickets that have been converted to ERC-20s.

stake

Stakes ERC20 tickets by burning their supply and creating an internal staked version.

Only a ticket holder or an operator can stake its tickets.

function stake(address _holder, uint256 _projectId, uint256 _amount)
external
override
requirePermissionAllowingWildcardDomain(_holder, _projectId, Operations.Stake);

Parameters

NameTypeDescription
_holderaddressThe owner of the tickets to stake.
_projectIduint256The ID of the project whos tickets are being staked.
_amountuint256The amount of tickets to stake.

unstake

Unstakes internal tickets by creating and distributing ERC20 tickets.

Only a ticket holder or an operator can unstake its tickets.

function unstake(address _holder, uint256 _projectId, uint256 _amount)
external
override
requirePermissionAllowingWildcardDomain(_holder, _projectId, Operations.Unstake);

Parameters

NameTypeDescription
_holderaddressThe owner of the tickets to unstake.
_projectIduint256The ID of the project whos tickets are being unstaked.
_amountuint256The amount of tickets to unstake.

lock

Lock a project's tickets, preventing them from being redeemed and from converting to ERC20s.

Only a ticket holder or an operator can lock its tickets.

function lock(address _holder, uint256 _projectId, uint256 _amount)
external
override
requirePermissionAllowingWildcardDomain(_holder, _projectId, Operations.Lock);

Parameters

NameTypeDescription
_holderaddressThe holder to lock tickets from.
_projectIduint256The ID of the project whos tickets are being locked.
_amountuint256The amount of tickets to lock.

unlock

Unlock a project's tickets.

The address that locked the tickets must be the address that unlocks the tickets.

function unlock(address _holder, uint256 _projectId, uint256 _amount) external override;

Parameters

NameTypeDescription
_holderaddressThe holder to unlock tickets from.
_projectIduint256The ID of the project whos tickets are being unlocked.
_amountuint256The amount of tickets to unlock.

transfer

Allows a ticket holder to transfer its tickets to another account, without unstaking to ERC-20s.

Only a ticket holder or an operator can transfer its tickets.

function transfer(address _holder, uint256 _projectId, uint256 _amount, address _recipient)
external
override
requirePermissionAllowingWildcardDomain(_holder, _projectId, Operations.Transfer);

Parameters

NameTypeDescription
_holderaddressThe holder to transfer tickets from.
_projectIduint256The ID of the project whos tickets are being transfered.
_amountuint256The amount of tickets to transfer.
_recipientaddressThe recipient of the tickets.