Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. contract UserBasic {
  2. bytes32 test;
  3. function getBytes(uint _value) constant returns(bytes32) {
  4. return test;
  5. }
  6. function setBytes(bytes32 _bytes) {
  7. test = _bytes;
  8. }
  9. }
  10.  
  11. {
  12. blockHash: "0x891546aa79223a100234098953f6c103140c910c64f1aaa1091eef37014c231b",
  13. blockNumber: 945,
  14. from: "0xc5756ccc9748e1a71b60eff8367543b42a0facf1",
  15. gas: 90000,
  16. gasPrice: 18000000000,
  17. hash: "0x47ab0461b3202f2b15a52ae866b445c64b2d30b0ede767689c702f8f17c61765",
  18. input: "0xe6748da93539393563653233383730346264373632303132373064390000000000000000",
  19. nonce: 4,
  20. r: "0xfbe02d3ee427c82274e50ee2771a7e305156e8a715dd86482a38da02d2bbacaa",
  21. s: "0x7a30b01680c44fdf134893cf2e422afa920f8b0435b7f50190fce7df28c37e51",
  22. to: "0xd705ef113e0a514a1dc9b84a7badd66fe84a3d57",
  23. transactionIndex: 0,
  24. v: "0xf0a",
  25. value: 0
  26. }
  27.  
  28. getBytes: function getBytes(contractAddress) {
  29. // Fetching the contract related data
  30. const input = fs.readFileSync('contracts/UserBasic.sol').toString();
  31. const output = solc.compile(input);
  32. const bytecode = output.contracts[':UserBasic'].bytecode;
  33. const abi = JSON.parse(output.contracts[':UserBasic'].interface);
  34. const contract = web3.eth.contract(abi).at(contractAddress);
  35. // Interaction with the contract
  36. contract.getRecords.call(2, (err, res) => {
  37. // Log transaction to explore
  38. if (err) {
  39. console.log(err);
  40. } else {
  41. console.log(res);
  42. }
  43. });
  44. },
  45. setBytes: function setBytes(publicAddress, contractAddress, _bytes) {
  46. // Fetching the contract related data
  47. const input = fs.readFileSync('contracts/UserBasic.sol').toString();
  48. const output = solc.compile(input);
  49. const bytecode = output.contracts[':UserBasic'].bytecode;
  50. const abi = JSON.parse(output.contracts[':UserBasic'].interface);
  51. const contract = web3.eth.contract(abi).at(contractAddress);
  52. // Interaction with the contract
  53. contract.setBytes(_bytes, {from: publicAddress}, (err, res) => {
  54. // Log transaction to explore
  55. if (err) {
  56. console.log(err);
  57. } else {
  58. console.log('tx: ' + res);
  59. }
  60. });
  61. }
  62.  
  63. []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement