Home

Awesome

BEAM's Crowdsale Contracts

Please see below BeamCrowdsale smart contracts for the BEAM crowdsale.

BEAM is an ERC-20 compliant cryptocurrency built on top of the Ethereum blockchain.

Contracts

Please see the contracts/ directory.

The Crowdsale Specification

BEAM PRICING PROGRAM

The price is set in USD, with the first token set at US$1. With every additional token sold, the price will increase by $(10^-9)

Develop

Code

BeamCrowdsale Functions

fallback

function () external payable onlyActualPrice onlyWhileOpen onlyWhitelisted whenNotPaused

Payable function to buy tokens.

finishCrowdsale

function finishCrowdsale() external onlyOwner onlyWhileOpen

Allows owner to finish the crowdsale.

claimFunds

function claimFunds() external

Transfers fund to contributor if the crowdsale has failed.

buyForFiat

function buyForFiat(address _beneficiary, uint256 _weiAmount) external onlyOwner onlyWhileOpen onlyActualPrice

Allows owner to add raising fund manually (tokens will purchase automatically).

mintBonus

function mintBonus(address _beneficiary, uint256 _tokenUnits) external onlyOwner onlyWhileOpen

Mints bonuses by admin.

finishSeedRound

function finishSeedRound() external onlyOwner onlyWhileOpen

Allows owner to finish the seed round.

setPublicRound

function setPublicRound(bool _enable) external onlyOwner onlyWhileOpen

Allows owner to start or renew public round. Function accesable only after the end of the seed round. If _enable is true, private round ends and public round starts. If _enable is false, public round ends and private round starts.

buyTokens

function buyTokens() public payable onlyWhileOpen onlyWhitelisted whenNotPaused onlyActualPrice

Low level token purchase.

tokenPrice

function tokenPrice() public view returns(uint256)

Returns the actual price of the token in USD units (1 USD unit = 1 * 10^-18 USD).

__callback

function __callback(bytes32 myid, string result, bytes proof) public

Receives the response from oraclize.

update

function update(uint256 _timeout) public payable

Cyclic query to update ETHUSD price. . Recieves response in one hour.

addAddressToWhitelist

function addAddressToWhitelist(address addr) public onlyOwner returns(bool success)

Adds an address to the whitelist.

addAddressesToWhitelist

function addAddressesToWhitelist(address[] addrs) public onlyOwner returns(bool success)

Adds addresses to the whitelist.

removeAddressFromWhitelist

function removeAddressFromWhitelist(address addr) public onlyOwner returns(bool success)

Removes an address from the whitelist.

removeAddressesFromWhitelist

function removeAddressesFromWhitelist(address[] addrs) public onlyOwner returns(bool success)

Removes addresses from the whitelist.

transferTokens

function transferTokens(address _beneficiary, uint256 _tokenAmount) external onlyOwner

Allows owner to transfer BEAM tokens.

pause

function pause() public onlyOwner whenNotPaused

Called by the owner to pause, triggers stopped state.

unpause

function unpause() public onlyOwner whenPaused

Called by the owner to unpause, returns to normal state.

transferOwnership

function transferOwnership(address newOwner) public onlyOwner

Allows the current owner to set the pendingOwner address.

claimOwnership

function claimOwnership() public onlyPendingOwner

Allows the pendingOwner address to finalize the transfer.

payToContract

function payToContract() external	payable	onlyOwner

Allows owner to send ETH to the contarct for paying fees or refund.

withdrawFunds

function withdrawFunds(address _beneficiary, uint256 _weiAmount) external onlyOwner

Allows owner to withdraw ETH from the contract balance.

BeamCrowdsale public variable

bonuses The amount of bonuses minted during the crowdsale (Those are bounty bonuses not discount).

crowdsaleFinished Whether the crowdsale has finished

decimals Decimals of the using token

funds Mapping contains addresses who and how much ETH invested.

increasing Increasing of the token price in units with each token emission.

lastPriceUpdate Timestamp of the last price updating.

owner Address of the current owner of the contract.

paused Whether the crowdsale is paused.

pendingOwner Address of the pending owner of the contract.

priceETHUSD Last price ETHUSD from oraclize in cents.

publicRound Whether the public round is active.

seedFinished Whether the seed round has finished.

softCap Soft cap amount in USD units.

softCapReached Whether the soft cap has reached.

token Address of the using token.

tokenPrice Current price of the one token in USD units.

tokensForSeed Amount of tokens for seed round.

centsInDollar How much cents in one dollar (100).

usdRaised How much USD was raised during the crowdsale.

wallet The address of a wallet specified by owner for forward funds for.

weiRaised Amount of wei was raised during the crowdsale.

whitelist Mapping contains 'true' as a value for addresses allowed to particioate in the crowdsale .

BeamCrowdsale Events

OwnershipTransferred

event GrantUpdated(address indexed _grantee, uint256 _oldAmount, uint256 _newAmount);

Pause

event Pause();

Unpause

event Unpause();

WhitelistedAddressAdded

event WhitelistedAddressAdded(address addr);

WhitelistedAddressRemoved

event WhitelistedAddressRemoved(address addr);

NewOraclizeQuery

event NewOraclizeQuery(string description);

PriceUpdated

event PriceUpdated(uint256 price);

TokenPurchase

event TokenPurchase(address indexed purchaser, uint256 value, uint256 amount);

SeedRoundFinished

event SeedRoundFinished();

PrivateRoundFinished

event PrivateRoundFinished();

StartPrivateRound

event StartPrivateRound();

StartPublicRound

event StartPublicRound();

PublicRoundFinished

event PublicRoundFinished();

CrowdsaleFinished

event CrowdsaleFinished(uint256 weiRaised, uint256 usdRaised);

SoftCapReached

event SoftCapReached();

Dependencies

# Install Truffle and ganache-cli packages globally:
$ npm install -g truffle ganache-cli

# Install local node dependencies:
$ npm install

Test

$ truffle test --network ganache

Deploy and manage

Use metamask to deploy the smart contracts. Copy code to remix browser. Compile the source and click deploy at the 'run' tab. Firstly, you need to deploy BeamToken.sol. Then copy address of this deployed contract and put it as a second parameter to constructor of BeamCrowdsale.sol. The first parameter is a wallet address for forward funds to. After deploying use method 'setManager' of BeamToken to set the BeamCrowdsale contract address as a manager of BeamToken. Then you will able to add addresses to whitelist and manage crowdsale and token using functions. Don't forget to send some ETH to the crowddsale contract to pay oraclize fees using 'update' or 'payToContract' functions. Notice 'update' function with parameter 'timeout' in seconds initiate new update cycle, while 'payToContract' just receives fund.

Code Coverage

$ ./node_modules/.bin/solidity-coverage

Collaborators

License

Apache License v2.0