2

I am trying to understand the RefundVault.sol contract from Open Zeppelin for implementing a soft cap that would refund investors if the cap is not reached. I am struggling t wrap my head around it, particularly how the enum for State works and how the crowdsale can interact with the contract to effect the mapping for deposited.

I thought that seeing a working example of this implemented would help but I can't find any. Does anyone have any links to code that use either this, or some other method for a soft cap refund functionality?

Thanks for any help.

  • Hi John, could you elaborate more on which part of RefundVault is confusing you? – martriay Feb 22 '18 at 14:59
  • For example, when you create a new RefundVault inside of the crowdsale you pass in an address in the constructor. What address should this be? Should I create an ethereum wallet address to act as the wallet for the RefundVault? How does this then keep the funds locked if I have created the wallet? Thank you very much for your help. – John Murphy Feb 22 '18 at 15:26
  • Also the close() function has the line: wallet.transfer(this.balance); Where is this transferring to, and from? Thanks again, the concepts in this contract are new to me. – John Murphy Feb 22 '18 at 15:58
3

For example, when you create a new RefundVault inside of the crowdsale you pass in an address in the constructor. What address should this be?

That's the crowdsale's wallet address.

The Crowdsale contract has a wallet state variable storing the addess to which the funds raised will be sent. The RefundVault contract used by the RefundableCrowdsale works as a vault for storing the funds until the crowdsale ends and decides whether to send the funds to the crowdsale's wallet address or refund the buyers depending on if the goal was reached or not.

Should I create an ethereum wallet address to act as the wallet for the RefundVault?

You need to generate an ethereum address under your control (this is, you have to own the associated private key) and pass it to the crowdsale on construction.

How does this then keep the funds locked if I have created the wallet?

Because the RefundableCrowdsale doesn't send the funds to the wallet but to the RefundVault instead. After the crowdsale, only if successful, the RefundVault will send the funds to the wallet you own. It's an intentional indirection to protect buyers in case of an unsuccessful crowdsale.

Also the close() function has the line: wallet.transfer(this.balance); Where is this transferring to, and from?

The transfer method of the address type takes an uint256 parameter and it sends that amount of wei from the caller to the address on which the method is called. In this case the caller (RefundVault) is sending all the wei in the contract (this.balance) to the wallet address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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