You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In DappTokenSale.sol:
function endSale() public {
require(msg.sender == admin);
require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))));
admin.transfer(address(this).balance);
}
In the test file DappTokenSale.js this is the entire test for the endSale() method:
it('ends token sale', function() {
return DappToken.deployed().then(function(instance) {
// Grab token instance first
tokenInstance = instance;
return DappTokenSale.deployed();
}).then(function(instance) {
// Then grab token sale instance
tokenSaleInstance = instance;
// Try to end sale from account other than the admin
return tokenSaleInstance.endSale({ from: buyer });
}).then(assert.fail).catch(function(error) {
assert(error.message.indexOf('revert') >= 0, 'must be admin to end sale');
// End sale as admin
return tokenSaleInstance.endSale({ from: admin });
}).then(function(receipt) {
return tokenInstance.balanceOf(admin);
}).then(async function(balance) {
assert.equal(balance.toNumber(), 999990, 'returns all unsold dapp tokens to admin');
// Check that the contract has no balance
await web3.eth.getBalance(tokenSaleInstance.address)
.then(contract_balance => assert.equal(contract_balance, 0));
});
});
!!!! async and await are necessary because calls to web3.eth return a promise and not a value straigtforward.
Getting this error while working on Video 63:
Uncaught (in promise) Error: Attempting to run transaction which calls a contract function, but recipient address 0xc9301a4af7c3e531293ae3539dcecfef2507db40 is not a contract address
at Object.InvalidResponse (web3.min.js:1)
at web3.min.js:2
at XMLHttpRequest.n.onreadystatechange (web3.min.js:2)
InvalidResponse @ web3.min.js:1
(anonymous) @ web3.min.js:2
n.onreadystatechange @ web3.min.js:2
Promise.then (async)
render @ app.js:76
(anonymous) @ app.js:43
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
y @ jquery.min.js:4
c @ jquery.min.js:4
XMLHttpRequest.send (async)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
n.(anonymous function) @ jquery.min.js:4
getJSON @ jquery.min.js:4
(anonymous) @ app.js:37
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
y @ jquery.min.js:4
c @ jquery.min.js:4
XMLHttpRequest.send (async)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
n.(anonymous function) @ jquery.min.js:4
getJSON @ jquery.min.js:4
initContracts @ app.js:30
initWeb3 @ app.js:26
init @ app.js:12
(anonymous) @ app.js:102
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
load (async)
add @ jquery.min.js:3
(anonymous) @ jquery.min.js:3
each @ jquery.min.js:2
each @ jquery.min.js:2
sa @ jquery.min.js:3
on @ jquery.min.js:3
(anonymous) @ bootstrap.min.js:6
(anonymous) @ bootstrap.min.js:6
Any idea about this one?
The text was updated successfully, but these errors were encountered: