Skip to main content

Coin Contract

The Coin contract implements an ERC20 stablecoin with additional functionality for the Monolith protocol. Contract implementation

Constructor

Initializes the stablecoin with a designated minter address, token name, and symbol. Parameters:
  • _minter: Address authorized to mint new tokens (Lender.sol)
  • name: ERC20 token name (e.g., “USD Coin”)
  • symbol: ERC20 token symbol (e.g., “USDC”)

User-Facing Functions

mint

Creates new tokens and assigns them to the specified address. Can only be called by the minter (Lender.sol). Parameters:
  • to: Address to receive the minted tokens
  • amount: Amount of tokens to mint (in wei, 18 decimals)
Requirements:
  • msg.sender must be the minter address (Lender.sol).
Events Emitted:
  • Transfer(address(0), to, amount)

burn

Destroys tokens from the caller’s balance, reducing the total supply. Parameters:
  • amount: Amount of tokens to burn from caller’s balance
Requirements:
  • Caller must have sufficient balance (balanceOf(msg.sender) >= amount)
Events Emitted:
  • Transfer(msg.sender, address(0), amount)

transfer

Standard ERC20 transfer function. Moves tokens from caller’s balance to another address. Parameters:
  • to: Recipient address
  • amount: Amount of tokens to transfer
Returns:
  • bool: Always returns true on successful transfer
Requirements:
  • Caller must have sufficient balance
Events Emitted:
  • Transfer(msg.sender, to, amount)

transferFrom

Standard ERC20 transferFrom function. Moves tokens from one address to another using allowance mechanism. Parameters:
  • from: Address to transfer tokens from
  • to: Recipient address
  • amount: Amount of tokens to transfer
Returns:
  • bool: Always returns true on successful transfer
Requirements:
  • from must have sufficient balance
  • Caller must have sufficient allowance from from
Events Emitted:
  • Transfer(from, to, amount)

approve

Standard ERC20 approve function. Allows spender to transfer up to amount tokens from caller’s balance. Parameters:
  • spender: Address authorized to spend tokens
  • amount: Maximum amount spender can transfer
Returns:
  • bool: Always returns true on successful approval
Events Emitted:
  • Approval(msg.sender, spender, amount)

View Functions

balanceOf

Returns the token balance of the specified address. Parameters:
  • account: Address to query balance for
Returns:
  • uint256: Token balance in wei

allowance

Returns the remaining allowance that spender can spend on behalf of owner. Parameters:
  • owner: Address that granted the allowance
  • spender: Address authorized to spend
Returns:
  • uint256: Remaining allowance amount

totalSupply

Returns the total supply of tokens in circulation. Returns:
  • uint256: Total token supply in wei

name

Returns the name of the token. Returns:
  • string: Token name

symbol

Returns the symbol of the token. Returns:
  • string: Token symbol

decimals

Returns the number of decimals used for token amounts. Returns:
  • uint8: Number of decimals (18 for this token)

minter

Returns the address authorized to mint new tokens (Lender.sol). Returns:
  • address: Minter address

Events

Transfer

Emitted when tokens are transferred, minted, or burned. Parameters:
  • from: Sender address (address(0) for mints)
  • to: Recipient address (address(0) for burns)
  • amount: Amount of tokens transferred

Approval

Emitted when allowance is set or changed. Parameters:
  • owner: Address granting the allowance
  • spender: Address receiving the allowance
  • amount: New allowance amount