Skip to content

ExternStateToken

Description

A partial ERC20 token contract, designed to operate with a proxy. To produce a complete ERC20 token, transfer and transferFrom tokens must be implemented, using the provided _byProxy internal functions.

For upgradeability, this contract utilises an external state contract to store its balances and allowances.

The main Synthetix contract and all Synths are ExternStateTokens.

Source: contracts/ExternStateToken.sol

Variables

decimals

Source

The ERC20 decimal precision of this token. This is usually set to 18 in Synthetix.

Type: uint8

name

Source

The ERC20 name of this token.

Type: string

symbol

Source

The ERC20 symbol of this token.

Type: string

tokenState

Source

The external state contract holding this token's balances and allowances.

Type: contract TokenState

totalSupply

Source

The ERC20 total token supply.

Type: uint256

Constructor

constructor

Source

Initialises this token's ERC20 fields, its proxy, token state, and its inherited SelfDestructible and Proxyable instances.

Details

Signature

constructor(address payable _proxy, contract TokenState _tokenState, string _name, string _symbol, uint256 _totalSupply, uint8 _decimals, address _owner)

Visibility

public

State Mutability

``

Views

allowance

Source

Returns the ERC20 allowance of one party to spend on behalf of another. This information is retrieved from the tokenState contract.

Details

Signature

allowance(address owner, address spender) view returns (uint256)

Visibility

public

State Mutability

view

balanceOf

Source

Returns the ERC20 token balance of the given address. This information is retrieved from the tokenState contract.

Details

Signature

balanceOf(address account) view returns (uint256)

Visibility

external

State Mutability

view

Restricted Functions

setTokenState

Source

Allows the owner to set the address of the tokenState(TokenState.md) contract. Unhooking the token state will pause the contract by causing all transactions to revert.

Details

Signature

setTokenState(contract TokenState _tokenState)

Visibility

external

State Mutability

``

Modifiers

Internal Functions

_internalTransfer

Source

Internal ERC20 transfer function used to implement _transfer_byProxy and _transferFrom_byProxy.

_internalTransfer always returns true if the transaction does not revert.

Details

Signature

_internalTransfer(address from, address to, uint256 value) returns (bool)

Visibility

internal

State Mutability

``

Requires

_transferByProxy

Source

Details

Signature

_transferByProxy(address from, address to, uint256 value) returns (bool)

Visibility

internal

State Mutability

``

_transferFromByProxy

Source

Details

Signature

_transferFromByProxy(address sender, address from, address to, uint256 value) returns (bool)

Visibility

internal

State Mutability

``

addressToBytes32

Source

Details

Signature

addressToBytes32(address input) pure returns (bytes32)

Visibility

internal

State Mutability

pure

emitApproval

Source

Details

Signature

emitApproval(address owner, address spender, uint256 value)

Visibility

internal

State Mutability

``

emitTokenStateUpdated

Source

Details

Signature

emitTokenStateUpdated(address newTokenState)

Visibility

internal

State Mutability

``

emitTransfer

Source

Details

Signature

emitTransfer(address from, address to, uint256 value)

Visibility

internal

State Mutability

``

External Functions

approve

Source

ERC20 approve function.

Details

Signature

approve(address spender, uint256 value) returns (bool)

Visibility

public

State Mutability

``

Modifiers

Events

Approval

Source

Records that an ERC20 approval occurred.

This event is emitted from the token's proxy with the emitApproval.

Signature: Approval(address owner, address spender, uint256 value)

TokenStateUpdated

Source

Records that the token state address was updated.

This event is emitted from the token's proxy with the emitTokenStateUpdated.

Signature: TokenStateUpdated(address newTokenState)

Transfer

Source

Records that an ERC20 transfer occurred.

This event is emitted from the token's proxy with the emitTransfer.

Signature: Transfer(address from, address to, uint256 value)