Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.11;
- contract Factory {
- address[] public pizzas;
- function Factory() {
- // constructor
- }
- function cookPizza() returns (address _pizza) {
- Pizza newPizza = new Pizza();
- pizzas.push(newPizza);
- return newPizza;
- }
- function getPizzas() public constant returns (address[]) {
- return pizzas;
- }
- }
- contract Pizza {
- function Pizza() {
- // constructor
- }
- }
- truffle(development)> Factory.deployed().then(function(instance) { factory = instance})
- undefined
- truffle(development)> factory.cookPizza()
- truffle(development)> factory.getPizzas()
- [ '0xc4f8cf2d5a37e74981fffdab1b2108931822359a' ]
- Running migration: 1_initial_migration.js
- Deploying Migrations...
- Migrations: 0x42e40188763019dd09a6166b76805d329bd71111
- Saving successful migration to network...
- Saving artifacts...
- Running migration: 2_deploy_contracts.js
- Deploying Factory...
- Factory: 0xb9d60d9ddf16e3af3bce774a1e9286ecf5614166
- Saving successful migration to network...
- Saving artifacts...
- > sender = eth.accounts[0]
- > abi = "abi"
- > contract = eth.contract(abi)
- > factory = contract.at("0xb9d60d9ddf16e3af3bce774a1e9286ecf5614166")
- > factory.cookPizza({from:sender})
- "0xf0ce6f4c0a9665f593d3d837eca4977b85d011dcb3620bf3a2428d25225db967"
- > factory.getPizzas()
- []
Add Comment
Please, Sign In to add comment