Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.7;
- contract SimpleStorage {
- uint public storedData;
- string public name = "ahmed";
- event Print(uint);
- function SimpleStorage(uint initialValue) {
- storedData = initialValue;
- }
- function set(uint x) returns (uint){
- storedData = x;
- Print(storedData);
- return storedData;
- }
- function get() constant returns (uint retVal) {
- return storedData;
- }
- }
- Error: Invalid JSON RPC response: ""
- web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/ahmed_charef"));
- contractAddress = "0x752fB8626c5bEf519EfC661F6694fbE497405FfE"
- ABI = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"","type":"uint256"}],"name":"Print","type":"event"}]
- myContract = web3.eth.contract(ABI).at(contractAddress);
- myContract.name(function(err, res){
- console.log(res);
- })
- function voteForCand() {
- myContract.set("20");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement