FTHM
https://github.com/Into-the-Fathom/fathom-dao-smart-contracts/blob/master/contracts/dao/tokens/MainToken.sol
The MainToken
contract is an ERC-20 token that includes standard functionalities for managing token balances, allowances, and transfers, following the OpenZeppelin library's specifications. It allows the minting of the initial supply upon deployment, which is assigned to a specified issuer. The contract also manages approvals and transfers from one account to another while ensuring that these operations adhere to the established ERC-20 standard, including handling edge cases like transfers to the zero address and ensuring sufficient balances and allowances for transfers and approvals.
Set Functions
transfer
Parameters:
to (
address
): The address to transfer tokens to.amount (
uint256
): The number of tokens to transfer.
Returns:
bool: Returns
true
if the transfer was successful.
Description: Transfers a specified amount of tokens from the caller's address to the specified address. Emits a
Transfer
event if successful.
approve
Parameters:
spender (
address
): The address which will spend the funds.amount (
uint256
): The amount of tokens they are allowed to spend.
Returns:
bool: Returns
true
if the approval was successful.
Description: Approves another address to spend a specified amount of tokens on behalf of the caller. Emits an
Approval
event.
transferFrom
Parameters:
from (
address
): The address to transfer tokens from.to (
address
): The address to transfer tokens to.amount (
uint256
): The number of tokens to transfer.
Returns:
bool: Returns
true
if the transfer was successful.
Description: Transfers a specified amount of tokens from one address to another, using the allowance mechanism. The caller must have a sufficient allowance from the
from
address. Emits aTransfer
event.
increaseAllowance
Parameters:
spender (
address
): The address which will spend the funds.addedValue (
uint256
): The additional amount of tokens they are allowed to spend.
Returns:
bool: Returns
true
if the operation was successful.
Description: Increases the allowance granted to another address by the caller. This is an alternative to calling
approve
for modifying allowances.
decreaseAllowance
Parameters:
spender (
address
): The address which will spend the funds.subtractedValue (
uint256
): The amount to decrease the allowance by.
Returns:
bool: Returns
true
if the operation was successful.
Description: Decreases the allowance granted to another address by the caller. This function will revert if the current allowance is less than the subtracted value.
Read Functions
name
Parameters: None
Returns:
string: The name of the token.
Description: Returns the name of the token as set during the contract initialization.
symbol
Parameters: None
Returns:
string: The symbol of the token.
Description: Returns the symbol of the token, used typically as a ticker-like identifier.
decimals
Parameters: None
Returns:
uint8: The number of decimals the token uses.
Description: Returns the number of decimals used by the token for display and calculations. Standard ERC-20 tokens typically use 18 decimals.
balanceOf
Parameters:
account (
address
): The address to query the balance of.
Returns:
uint256: The number of tokens owned by the
account
.
Description: Queries the balance of the specified address. Returns the amount of tokens that the address currently holds.
totalSupply
Parameters: None
Returns:
uint256: The total token supply.
Description: Returns the total amount of tokens in existence.
allowance
Parameters:
owner (
address
): The address of the owner of the tokens.spender (
address
): The address of the spender allowed to use the tokens.
Returns:
uint256: The remaining number of tokens that the spender will be allowed to spend on behalf of the owner.
Description: Returns the remaining number of tokens that the spender is allowed to spend on behalf of the owner through
transferFrom
.
Events
Transfer
Parameters:
from (
address
): The address transferring the tokens.to (
address
): The address receiving the tokens.value (
uint256
): The amount of tokens being transferred.
Description: Emitted when
value
tokens are moved from one account (from
) to another (to
).
Approval
Parameters:
owner (
address
): The address of the token owner.spender (
address
): The address approved to spend the tokens.value (
uint256
): The amount of tokens approved for spending.
Description: Emitted when
owner
approvesspender
to spendvalue
tokens on their behalf.
Last updated