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 Oikos contract and all Synths are ExternStateTokens.

Source: ExternStateToken.sol

Architecture


Inheritance Graph

ExternStateToken inheritance graph



Libraries


Variables


tokenState

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

Type: TokenState public


name

The ERC20 name of this token.

Type: string public


symbol

The ERC20 symbol of this token.

Type: string public


totalSupply

The ERC20 total token supply.

Type: uint public


decimals

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

Type: uint8 public


Functions


constructor

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

Details

Signature

constructor(address _proxy, TokenState _tokenState, string _name, string _symbol, uint _totalSupply, uint8 _decimals, address _owner) public

Superconstructors


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) public view returns (uint)


balanceOf

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

Details

Signature

balanceOf(address account) public view returns (uint)


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(TokenState _tokenState) external

Modifiers

Emits


_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, uint value, bytes data) internal returns (bool)

Preconditions

  • The recipient cannot be the zero address.
  • The recipient cannot be the token contract itself.
  • The recipient cannot be the proxy.
  • The sender's token balance must not be less than value.

Emits


_transfer_byProxy

Designed to be used in a transfer function posessing the onlyProxy modifier in an inheriting contract.

Implemented as _internalTransfer(from, to, value).

Details

Signature

_transfer_byProxy(address from, address to, uint value) internal returns (bool)

Other details are as per _internalTransfer


_transferFrom_byProxy

Designed to be used in a transferFrom function posessing the onlyProxy modifier in an inheriting contract.

After allowance has been deducted, Implemented by _internalTransfer(from, to, value, data).

Details

Signature

_transferFrom_byProxy(address sender, address from, address to, uint value, bytes data) internal returns (bool)

Preconditions

  • The sender must have an approval greater than value.

Other details are as per _internalTransfer


approve

ERC20 approve function.

Details

Signature

approve(address spender, uint value) public returns (bool)

Modifiers

Emits


Events


Transfer

Records that an ERC20 transfer occurred.

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

Signature: Transfer(address indexed from, address indexed to, uint value)


Approval

Records that an ERC20 approval occurred.

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

Signature: Approval(address indexed owner, address indexed spender, uint 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)