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.
wallet.transfer(this.balance);
Where is this transferring to, and from? Thanks again, the concepts in this contract are new to me.