Guest User

Untitled

a guest
Oct 20th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. // A very simple Money contract. It knows its name and territory.
  2.  
  3. contract Money {
  4. string name;
  5. string territory;
  6.  
  7. constructor(string _name, string _territory) public {
  8. name = _name;
  9. territory = _territory;
  10. }
  11.  
  12. function moneyName() public constant returns (string){
  13. return name;
  14. }
  15. }
  16.  
  17. contract Banker {
  18. string name;
  19. address[] public contracts;
  20.  
  21. constructor(string _name) public {
  22. name = _name;
  23. }
  24.  
  25. function createMoney (string _name, string _territory) public{
  26. Money m = new Money(_name, _territory);
  27. contracts.push(m);
  28. }
  29.  
  30. function howMany() public constant returns (uint){
  31. return contracts.length;
  32. }
  33.  
  34. function showMoney(uint index) public constant returns (address) {
  35. assert (index < contracts.length);
  36.  
  37. // You can use the address returned to fetch the money contract.
  38. return contracts[index];
  39. }
  40.  
  41. }
Add Comment
Please, Sign In to add comment