0

I am learning soildity.

I created a fixed supply token. My token supply is 1000000 with 0 decimal places. Now, I want to transfer tokens from using new contract, so I created a new contract named Crowdsale. Whenever I am transfring the token from crowdsale contract it gives an error.

"transact to Crowdsale.(fallback) errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The constructor should be payable if you send value. Debug the transaction to get more information. "

Note: I am passing the token owner address to the Crowdsale contract at the time of deploying.

you can find my contract using below link:

https://github.com/maksa14/Contracts/blob/master/Test/TokenCrowdsale.sol

0

The address that you need to pass is the token contract address not the address of the owner. This doesn't show an error when you do it. However, your code has some issues:

This function:

function transferToken (address _to, uint256 _tokenAmount) public returns (bool) {
        return token.transfer(_to,_tokenAmount);
    }

will trigger the transfer function in token but the msg.sender here is not who originate the transaction. msg.sender here is the crowdsalecontract address, which doesn't have any tokens and the function will always return false.

You can transfer all the tokens to crowdsale contract first, so that it can sell it to the users.

Hope this helps

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.