when i try to run the ratings contract on mix (ethereum v0.9.92) windows 64bit. I'm getting this error thrown. It was working until a couple versions prior to this. can anyone help me find the problem. the contract/html code is exact from the tutorial here
I'm just trying Mix for the first time using the tutorial and still get a similar error:
web3.js - line 3881 - Uncaught invalid address
(Shouldn't that issue either be corrected or an explanation added to the tutorial?)
My problem: I don't know how to display the JS console to enter the proposed command? I cannot find a corresponding menu point in Mix. Any help would be appreciated!
The JS console can be displayed by clicking a command button in the Web View, which in turn can be displayed from the menu bar using Windows --> Show Web View. There are two command buttons to the right of the address bar in the Web View. Use the command button furthest to the right to open the JS console.
Go to Windows, select only "Show Web View", now by clicking on the button to the right of the check box "Auto reload on save" and you will launch the JS Console. Once you have this copy the above code to set the default account -- web3.eth.defaultAccount = web3.eth.accounts[0]
Since it is a javascript command, in my understanding you must add the code web3.eth.defaultAccount = web3.eth.accounts[0]; to your javascript file. Or inside your html between javascript tags. It is missing in the sample contract, so it is confusing. If you input via js console it is in fact a workaround.
function get() { var param = document.getElementById('query').value; var res = contracts['Sample'].contract.get(); document.getElementById('queryres').innerText = res; }
function set() { var key = document.getElementById('key').value; var res = contracts['Sample'].contract.set(key); }
Since it is a javascript command, in my understanding you must add the code web3.eth.defaultAccount = web3.eth.accounts[0]; to your javascript file. Or inside your html between javascript tags. It is missing in the sample contract, so it is confusing. If you input via js console it is in fact a workaround.
Either within the javascript file, or as a command into the javascript console, as mentioned by dur
Comments
You have to the set the defaultAccount to be used:
web3.eth.defaultAccount = web3.eth.accounts[0]
My problem: I don't know how to display the JS console to enter the proposed command? I cannot find a corresponding menu point in Mix. Any help would be appreciated!
contract["NAME"].contract.function(param1, param2, { from: "0x...." })
Or inside your html between javascript tags.
It is missing in the sample contract, so it is confusing.
If you input via js console it is in fact a workaround.
open js tag
///////////////////////////////////////////////////////////////////////// HERE IT IS !
web3.eth.defaultAccount = web3.eth.accounts[0];
/////////////////////////////////////////////////////////////////////////
function get() {
var param = document.getElementById('query').value;
var res = contracts['Sample'].contract.get();
document.getElementById('queryres').innerText = res;
}
function set() {
var key = document.getElementById('key').value;
var res = contracts['Sample'].contract.set(key);
}
close js tag