跳到主要内容

JBV3Token

An ERC-20 token that can be used by a project in the JBTokenStore & also this takes care of the migration of the V1 & V2 project tokens for V3.

Git Source

Inherits: ERC20Permit, Ownable, ReentrancyGuard, IJBTokenV3

Adheres to:

  • IJBTokenV3: Allows this contract to be used by projects in the JBTokenStore.

Inherits from:

  • ERC20Permit: General ERC20 token standard for allowing approvals to be made via signatures.
  • Ownable: Includes convenience functionality for checking a message sender's permissions before executing certain transactions.

State Variables

projectId

The ID of the project that this token should be exclusively used for.

uint256 public immutable override projectId;

v1TicketBooth

The V1 Token Booth instance.

ITicketBooth public immutable v1TicketBooth;

v2TokenStore

The V2 Token Store instance.

IJBTokenStore public immutable v2TokenStore;

v1ProjectId

Storing the v1 project ID to migrate to the v3 project ID.

uint256 public immutable v1ProjectId;

Functions

totalSupply

The total supply of this ERC20.

Includes the V3 token balance as well as unmigrated V1 and V2 balances.

function totalSupply(uint256 _projectId) external view override returns (uint256);

Parameters

NameTypeDescription
_projectIduint256the ID of the project to which the token belongs. This is ignored.

Returns

NameTypeDescription
<none>uint256The total supply of this ERC20, as a fixed point number.

totalSupply

The total supply of this ERC20.

Includes the V3 token balance as well as unmigrated V1 and V2 balances.

function totalSupply() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The total supply of this ERC20, as a fixed point number.

balanceOf

An account's balance of this ERC20.

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

Parameters

NameTypeDescription
_accountaddressThe account to get a balance of.
_projectIduint256is the ID of the project to which the token belongs. This is ignored.

Returns

NameTypeDescription
<none>uint256The balance of the _account of this ERC20, as a fixed point number with 18 decimals.

decimals

The number of decimals included in the fixed point accounting of this token.

function decimals() public view override(ERC20, IJBTokenV3) returns (uint8);

Returns

NameTypeDescription
<none>uint8The number of decimals.

constructor

constructor(
string memory _name,
string memory _symbol,
uint256 _projectId,
ITicketBooth _v1TicketBooth,
IJBTokenStore _v2TokenStore,
uint256 _v1ProjectId
) ERC20(_name, _symbol) ERC20Permit(_name);

Parameters

NameTypeDescription
_namestringThe name of the token.
_symbolstringThe symbol that the token should be represented by.
_projectIduint256The V3 ID of the project that this token should exclusively be used for.
_v1TicketBoothITicketBoothV1 Token Booth instance, if V1 migration is desired.
_v2TokenStoreIJBTokenStoreV2 Token Store instance, if V2 migration is desired.
_v1ProjectIduint256V1 project ID that this token should include.

mint

Mints more of the token.

Only the owner of this contract can mint more of it.

function mint(uint256 _projectId, address _account, uint256 _amount) external override onlyOwner;

Parameters

NameTypeDescription
_projectIduint256The ID of the project to which the token belongs.
_accountaddressThe account to mint the tokens for.
_amountuint256The amount of tokens to mint, as a fixed point number with 18 decimals.

burn

Burn some outstanding tokens.

Only the owner of this contract cant burn some of its supply.

function burn(uint256 _projectId, address _account, uint256 _amount) external override onlyOwner;

Parameters

NameTypeDescription
_projectIduint256The ID of the project to which the token belongs. This is ignored.
_accountaddressThe account to burn tokens from.
_amountuint256The amount of tokens to burn, as a fixed point number with 18 decimals.

approve

Approves an account to spend tokens on the msg.senders behalf.

function approve(uint256 _projectId, address _spender, uint256 _amount) external override;

Parameters

NameTypeDescription
_projectIduint256the ID of the project to which the token belongs. This is ignored.
_spenderaddressThe address that will be spending tokens on the msg.senders behalf.
_amountuint256The amount the _spender is allowed to spend.

transfer

Transfer tokens to an account.

function transfer(uint256 _projectId, address _to, uint256 _amount) external override;

Parameters

NameTypeDescription
_projectIduint256The ID of the project to which the token belongs. This is ignored.
_toaddressThe destination address.
_amountuint256The amount of the transfer, as a fixed point number with 18 decimals.

transferFrom

Transfer tokens between accounts.

function transferFrom(uint256 _projectId, address _from, address _to, uint256 _amount) external override;

Parameters

NameTypeDescription
_projectIduint256The ID of the project to which the token belongs. This is ignored.
_fromaddressThe originating address.
_toaddressThe destination address.
_amountuint256The amount of the transfer, as a fixed point number with 18 decimals.

migrate

Migrate v1 & v2 tokens to v3.

function migrate() external nonReentrant;

_migrateV1Tokens

Migrate V1 tokens to V3.

function _migrateV1Tokens() internal returns (uint256 v3TokensToMint);

Returns

NameTypeDescription
v3TokensToMintuint256The amount of V1 tokens to be migrated.

_migrateV2Tokens

Migrate V2 tokens to V3.

function _migrateV2Tokens() internal returns (uint256 v3TokensToMint);

Returns

NameTypeDescription
v3TokensToMintuint256The amount of V2 tokens to be migrated.

Errors

BAD_PROJECT

error BAD_PROJECT();