dappuniversity / token_sale

Code Your Own Cryptocurrency & ICO on Ethereum | Tutorial
406 stars 387 forks source link

Issue on purchase #21

Open Nicholasw22 opened 5 years ago

Nicholasw22 commented 5 years ago

After I select a token for purchase, I get the below error

ALERT: [ethjs-rpc] rpc error with payload {"id":8115156641523,"jsonrpc":"2.0","params":["0xf892058504a817c8008307a12094fc4878e9ab8e9e9278ab6927d9b7b1a73502fe2887038d7ea4c68000a43610724e0000000000000000000000000000000000000000000000000000000000000001822d45a0d540ee24845101bce60f0e962406b5a7a7c18576bea9fa7311287a76bb52c433a0594c832caa47e93b5041fca934938ca23a078ed2cea0b6813d7279b454baf876"],"method":"eth_sendRawTransaction"} Error: VM Exception while processing transaction: revert

officialfrancismendoza commented 5 years ago

Did you load tokens into your smart contract first? You have to go into truffle console and type in certain commands to load it first. It's roughly in 6:36:00 in the video tutorial

anonymity12 commented 5 years ago

thanks to fmendoz7

so here are what shall we do, when we want to test buyTokens on our local browser:

truffle(development)> 

DappTokenSale.deployed().then(function(i) { tokenSale = i;})

DappToken.deployed().then(function(i) { token = i;})

ruffle(development)> tokensAvailable = 750000;
750000
truffle(development)> accAddrs = await web3.eth.getAccounts()
undefined
truffle(development)> admin = accAddrs[0]
'0x9F156845Ed0ae8362094cE68DbFD68B25EEba7B4'
truffle(development)>token.transfer(tokenSale.address, tokensAvailable, {from: admin})

then you can buyTokens