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); }
/script /head
body bgcolor='#E6E6FA' h3 Sample Ratings /h3 div Store: input type='number' id='key' button onclick='set()'Save/button /div div Query: input value='get' type='button' id='query' onclick='get()' / div id='queryres' /div /div /body /html
hm ok for now the official ethereum html/web browser is mist https://gitter.im/ethereum/mist If you really want to use a "normal" browser. You'll have to ship web3.js library in the packag, Instanciate a new web3 object and then set the api provider like : web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
I love you Yann. Yes, that's what I expected,simple html + js not sure why I got lost with Mix and Mist and Alethzero and meteor and truffle. This is perfect for a noob like me. It works! Thanks. So easy!
Hi, I'm developping an Sample Dapp with Mix and I'm in the same case of maxxflyer at the begining of this post. I would like to use my dapp with a "normal" browser and I don't know how to ship web3.js library in the package produced by Mix and where instanciate the new web3 object.
Comments
//Sample contract
contract Sample
{
uint value;
function Sample(uint v) {
value = v;
}
function set(uint v) {
value = v;
}
function get() constant returns (uint) {
return value;
}
}
!doctype
html
head
script type='text/javascript'
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);
}
/script
/head
body bgcolor='#E6E6FA'
h3 Sample Ratings /h3
div
Store:
input type='number' id='key'
button onclick='set()'Save/button
/div
div
Query:
input value='get' type='button' id='query' onclick='get()' /
div id='queryres' /div
/div
/body
/html
// Autogenerated by Mix
contracts = {};
ctrAddresses = {};
contracts["Sample"] = {
interface: [{"constant":false,"inputs":[{"name":"v","type":"uint256"}],"name":"set","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"inputs":[{"name":"v","type":"uint256"}],"type":"constructor"}],
address: "0xf4ce3093759deb93e087d7462237b08b1b9a6502"
};
contracts["Sample"].contractClass = web3.eth.contract(contracts["Sample"].interface);
contracts["Sample"].contract = contracts["Sample"].contractClass.at(contracts["Sample"].address);
contracts[""] = {
interface: [{"constant":false,"inputs":[{"name":"v","type":"uint256"}],"name":"set","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"inputs":[{"name":"v","type":"uint256"}],"type":"constructor"}],
address: "0xf4ce3093759deb93e087d7462237b08b1b9a6502"
};
contracts[""].contractClass = web3.eth.contract(contracts[""].interface);
contracts[""].contract = contracts[""].contractClass.at(contracts[""].address);
if (!ctrAddresses["Sample"]){ ctrAddresses["Sample"] = [] }ctrAddresses["Sample"].push("0xf4ce3093759deb93e087d7462237b08b1b9a6502")
You should browse index.html using Mist
If you really want to use a "normal" browser. You'll have to ship web3.js library in the packag, Instanciate a new web3 object and then set the api provider like : web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
I'm developping an Sample Dapp with Mix and I'm in the same case of maxxflyer at the begining of this post. I would like to use my dapp with a "normal" browser and I don't know how to ship web3.js library in the package produced by Mix and where instanciate the new web3 object.
Thanks for advance for your reply !
ps : Sorry for my poor english ^^