Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. — A.makeCall({gas:300000}); // NO ERRORS
  2. — A.sender(); // 0x0000000000000000000000000000000000000000 AS EXPECTED
  3. — A.myVar(); // 0 AS EXPECTED
  4. — B.sender(); // addressA AS EXPECTED
  5. — B.myVar(); // 1 AS EXPECTED
  6.  
  7. — A.reset({gas: 300000}); // NO ERRORS;
  8.  
  9. — A.sender(); // 0x0000000000000000000000000000000000000000 AS EXPECTED
  10. — A.myVar(); // 0 AS EXPECTED
  11. — B.sender(); // 0x0 AS EXPECTED
  12. — B.myVar(); // 0 AS EXPECTED
  13.  
  14. — A.makeCallCode({gas:300000}); // NO ERRORS
  15. — A.sender(); // 0x0000000000000000000000000000000000000002 Oops! It looks like there was no access to msg.sender and sender variable was assigned argument x instead.
  16. — A.myVar(); // 0 Oops! Nothing was assigned, because of the ↑
  17. — B.sender(); // 0x0 AS EXPECTED
  18. — B.myVar(); // 0 AS EXPECTED
  19.  
  20. — A.reset({gas: 300000}); //ALL KIND OF ERRORS; WTF IS GOING ON HERE? NO MATTER HOW MUCH GAS I SUPPLY IT STILL FAILS. https://testnet.etherscan.io/tx/0x6654b6739f55690c7114fa9e8cfb7a5959e73d60c37782aee4e211487de859f2
  21.  
  22. contract A {
  23. address public addressB;
  24. address public sender;
  25. uint public myVar;
  26.  
  27. function A() {
  28. addressB = new B();
  29. }
  30.  
  31. function makeCall(){
  32. addressB.call(bytes4(sha3('set(uint256)')), 1);
  33. }
  34. function makeCallCode(){
  35. addressB.callcode(bytes4(sha3('set(uint256)')), 2);
  36. }
  37. function makeDelegateCall(){
  38. addressB.delegatecall(bytes4(sha3('set(uint256)')), 3);
  39. }
  40.  
  41. function reset(){
  42. sender = 0;
  43. myVar = 0;
  44. B(addressB).reset();
  45. }
  46. }
  47.  
  48. contract B {
  49. address public sender;
  50. uint public myVar;
  51.  
  52. function set(uint x){
  53. myVar = x;
  54. sender = msg.sender;
  55. }
  56. function reset(){
  57. sender = 0;
  58. myVar = 0;
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement