Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. pragma solidity ^0.4.7;
  2. contract SimpleStorage {
  3.  
  4. uint public storedData;
  5. string public name = "ahmed";
  6. event Print(uint);
  7.  
  8. function SimpleStorage(uint initialValue) {
  9. storedData = initialValue;
  10. }
  11.  
  12. function set(uint x) returns (uint){
  13. storedData = x;
  14. Print(storedData);
  15. return storedData;
  16. }
  17.  
  18. function get() constant returns (uint retVal) {
  19. return storedData;
  20. }
  21. }
  22.  
  23. Error: Invalid JSON RPC response: ""
  24.  
  25. web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/ahmed_charef"));
  26.  
  27. contractAddress = "0x752fB8626c5bEf519EfC661F6694fbE497405FfE"
  28. 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"}]
  29.  
  30. myContract = web3.eth.contract(ABI).at(contractAddress);
  31.  
  32. myContract.name(function(err, res){
  33. console.log(res);
  34. })
  35.  
  36. function voteForCand() {
  37.  
  38. myContract.set("20");
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement