The TokenPresale smart contract facilitates the sale of a specific ERC-20 token at a predetermined rate in exchange for Ether (ETH). It includes features such as pausing, ownership control, and a cap on the total ETH that can be raised during the presale.
token
: The ERC-20 token being sold.rate
: The rate at which tokens are exchanged for ETH, denominated in wei.cap
: The maximum amount of ETH that can be raised during the presale.weiRaised
: Total amount of ETH raised so far.tokenAddress
: The address of the ERC-20 token contract.tokensPurchased
: Mapping to keep track of the amount of tokens purchased by each beneficiary.claimedAmount
: Mapping to track the amount of tokens claimed by each beneficiary.
Description: Constructor to initialize the smart contract with the token rate and cap. Parameters:
_rate
: Token rate per ETH (wei)._cap
: Cap in ETH (wei).
Description: Allows users to purchase tokens by sending ETH to the contract. Parameters:
beneficiary
: The address that will receive the purchased tokens.
Description: Provides an estimate of the number of tokens a user can buy with a specific amount of ETH. Parameters:
_weiAmount
: The amount of ETH in wei.
Description: Allows users to claim their purchased tokens.
Description: Allows the owner to withdraw the ETH balance from the contract.
Description: Allows the owner to pause the presale.
Description: Allows the owner to unpause the presale.
Description: Returns the number of tokens available for sale in the contract.
Description: Fallback function to allow users to send ETH and purchase tokens.
Parameters:
purchaser
: The address that initiated the token purchase.beneficiary
: The address that will receive the purchased tokens.value
: The amount of ETH sent.amount
: The amount of tokens purchased.
Parameters:
beneficiary
: The address that claimed the tokens.amount
: The amount of tokens claimed.