- You are right. You need to return something in your getLeftTokens function. You also made a mistake in your return clause, it should only contain a return type. So if balanceOf returns an uint, you can write like this.
function getLeftTokens() public view returns(uint) {
return token.balanceOf(address(this));
}
- HD wallet provider has been moved, correct. I’m very happy that you are exploring on your own, you will learn A TON. The documentation for the HDWalletProvider has been moved to truffle and you can find it here. I think you will be able to put the pieces together after reading through the ReadMe.
- First thing, which if statement block are we talking running within when you are executing it? I assume it’s the first one, where the funding goal is not reached. I also assume you are not getting any error messages? And how are you checking if no money is being withdrawn?
Looks kinda weird in it’s current state. You first have a transfer call, then you have another send call. They do the same thing, and right now you have quite a nasty bug where the balance will be withdrawn 2 times and the balanceOfShare could be corrupted.
Because first you withdraw all the money to the sender using transfer(). Now the actual balance is 0. Then you do send() with the same amount. This might fail since the contract is out of money, if it fails, then you reset the users balance to what it was before. Your issues might be coming from this.