2

I am learning to develop smart contract using Solidity. Currently, I am working and test the feature of following crowdsale contract.

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v1.8.0/contracts/crowdsale/Crowdsale.sol

This contract constructor has three different values.

  1. rate
  2. wallet address
  3. token address

I am confused about the first one that is "rate". what value should i have to pass here ?

for example, I want to sell 1 token at cost of 1 ether then what should i pass here ?

3 Answers 3

2

As you can see the function

function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
    return _weiAmount.mul(rate);
  }

It states that for 1 wei, the no of tokens will be 1*rate.

for example, I want to sell 1 token at cost of 1 ether then what should i pass here ?

This depends on number of decimals in your toke contract. For eg, if you have 18 decimals,then

token = wei * rate

1 Token = 1 ether * rate

10 ^18 token = 10 ^18 wei * rate

=> rate = 1
6
  • I have deployed the crowdsale contract with my fixed supply token but it gives an exection.
    – Sandeep
    Commented Jun 22, 2018 at 7:29
  • my fixed supply has 18 decimal
    – Sandeep
    Commented Jun 22, 2018 at 7:30
  • exception is constructor should be payable if you send the value
    – Sandeep
    Commented Jun 22, 2018 at 7:31
  • You need to make any function that accepts ether payable Commented Jun 22, 2018 at 10:58
  • you can see in my crowdsale contract there is a function name buyTokens() that is payable.
    – Sandeep
    Commented Jun 23, 2018 at 5:24
0

http://eth-converter.com/

Wei to Ether

Wei is the 18 digits that go into an Ether

0

Rate is explained in the OpenZeppelin Contracts Crowdsale documentation: https://docs.openzeppelin.com/contracts/2.x/crowdsales#crowdsale-rate

You can also ask questions about how to use OpenZeppelin Contracts in the Community Forum

Disclosure: I am the the Community Manager at OpenZeppelin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.