dappuniversity / token_sale

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

Missing From Videos #19

Open mmcc1 opened 5 years ago

mmcc1 commented 5 years ago
  1. How to get an instance which will permit the call of endSale()?
  2. How to get the Ether from the sale contract?
mmcc1 commented 5 years ago

I took the ABI from the token sale json and the network address and got an instance of the token sale contract. From there I was able to call endSale().

But I just get an error. The account I am using on Geth is the admin account.

var TokenContract = web3.eth.contract(abi)
var tokenInstance = TokenContract.at('address')

> tokenInstance.endSale()
Error: invalid address
    at web3.js:3930:15
    at web3.js:3756:20
    at web3.js:5025:28
    at map (<native code>)
    at web3.js:5024:12
    at web3.js:5050:18
    at web3.js:5075:23
    at web3.js:4137:16
    at apply (<native code>)
    at web3.js:4223:16
mmcc1 commented 5 years ago

The solution to the above error is:

web3.eth.defaultAccount = web3.eth.accounts[0]

Make sure to check the repo for code to transfer the balance in Ether.