Protocol Token
1. Summary
The protocol token is a DsDelegateToken that provides logic for burning and authorized minting of new tokens as well as delegation capabilities.
2. Contract Variables & Functions
Variables
guy- user addresswad- a quantity of tokens, usually as a fixed point integer with 10^18 decimal places.dst- refers to the destination address.name- returns the name of the token - e.g. "MyToken".symbol- token symbol.decimals- returns the number of decimals the token uses.totalSupply- returns the total token supply.balanceOf(usr: address)- user balancedelegates(usr: address)- a record of each account's delegatecheckpoints(usr: address,checkpoint: uint32)- a record of vote checkpoints for each account, by indexnumCheckpoints(usr: address)- the number of checkpoints for each accountnonces(usr: address)- a record of states for signing / validating signaturesallowance(src: address, dst: address)- approvalsbalanceOf(usr: address)- returns the account balance of another account with address _owner.allowance(src: address, dst: address)- returns the amount which _spender is still allowed to withdraw from _owner.DOMAIN_TYPEHASH- the EIP-712 typehash for the contract's domainDELEGATION_TYPEHASH- the EIP-712 typehash for the delegation struct used by the contract
Functions
mint(usr: address,amount: uint256)- mint coins to an addressburn(usr: address,amount: uint256)- burn at an addresspush(usr: address,amount: uint256)- transferpull(usr: address,amount: uint256)- transfer frommove(src: address,dst: address,amount: uint256)- transfer fromapprove(usr: address,amount: uint256)- allow pulls and movestransfer(dst: address,amount: uint256)- transfers coins frommsg.sendertodstdelegate(delegatee: address)- delegate votes frommsg.sendertodelegateedelegateBySig(delegatee: address,nonce: uint256,expiry: uint256,v: uint8,r: bytes32,s: bytes32)- delegates votes from signatory todelegateegetCurrentVotes(account: address) external view returns (uint256)- gets the current votes balance foraccountgetPriorVotes(account: address,blockNumber: uint256) public view returns (uint256)- determine the prior number of votes for an account as of a block number
Data Structures
Checkpoint- stores a checkpoint's data. Contains:fromBlock- the block from which that amount of votes has been markedvotes- the amount of votes
Events
Mint- emitted when new tokens are minted. Contains:guy- the address for which the contract prints tokenswad- the amount of tokens printed
Burn- emitted when tokens are burned. Contains:guy- the address whose tokens are burnedwad- the amount of tokens that were burned
DelegateChanged- emitted when an address changes its delegate. Contains:delegator- the address that changes its delegatefromDelegate- the old delegatetoDelegate- the new delegate
DelegateVotesChanged- emitted when a delegate account's vote balance changes. Contains:delegate- the delegate accountpreviousBalance- the delegate's previous vote balancenewBalance- the delegate's new vote balance
3. Walkthrough
Along with the standard ERC20 token interface, the protocol token also has DSAuth-protected mint and burn functions.