Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2016
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. contract ExampleAPI {
  2. function getNumber() constant returns (uint256) {}
  3. }
  4.  
  5. contract Example {
  6.  
  7. uint256 num;
  8. address parent;
  9.  
  10. function Example(uint256 _num, address _parent) {
  11. num = _num;
  12. parent = _parent;
  13. }
  14.  
  15. function getNumber() constant returns (uint256) {
  16. return num;
  17. }
  18.  
  19. function getParentNumber() constant returns (uint256) {
  20. ExampleAPI e = ExampleAPI(parent);
  21. return e.getNumber();
  22. }
  23.  
  24. }
  25.  
  26. contract ExampleFactory {
  27.  
  28. function create(address parent) {
  29. address NULL_ADDRESS;
  30. uint256 num = 0;
  31. if (parent != NULL_ADDRESS) {
  32. Example e = Example(parent);
  33. num = e.getNumber() + 1;
  34. }
  35. Example child = new Example(num, parent);
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement