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
¶
The ERC20 decimal precision of this token. This is usually set to 18 in Synthetix.
Type: uint8
name
¶
The ERC20 name of this token.
Type: string
symbol
¶
The ERC20 symbol of this token.
Type: string
tokenState
¶
The external state contract holding this token's balances and allowances.
Type: contract TokenState
totalSupply
¶
The ERC20 total token supply.
Type: uint256
Constructor¶
constructor
¶
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
¶
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
¶
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
¶
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
¶
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
¶
Details
Signature
_transferByProxy(address from, address to, uint256 value) returns (bool)
Visibility
internal
State Mutability
``
_transferFromByProxy
¶
Details
Signature
_transferFromByProxy(address sender, address from, address to, uint256 value) returns (bool)
Visibility
internal
State Mutability
``
addressToBytes32
¶
Details
Signature
addressToBytes32(address input) pure returns (bytes32)
Visibility
internal
State Mutability
pure
emitApproval
¶
Details
Signature
emitApproval(address owner, address spender, uint256 value)
Visibility
internal
State Mutability
``
emitTokenStateUpdated
¶
Details
Signature
emitTokenStateUpdated(address newTokenState)
Visibility
internal
State Mutability
``
emitTransfer
¶
Details
Signature
emitTransfer(address from, address to, uint256 value)
Visibility
internal
State Mutability
``
External Functions¶
approve
¶
ERC20 approve function.
Details
Signature
approve(address spender, uint256 value) returns (bool)
Visibility
public
State Mutability
``
Modifiers
Events¶
Approval
¶
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
¶
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
¶
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)