Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- contract Product{
- address public owner;
- string public title;
- mapping (address => uint) quantity;
- event Transferred(address from, address to, uint quantity);
- // Constructor
- function Product(string _title, uint _quantity){
- owner = msg.sender;
- title = _title;
- quantity[msg.sender] = _quantity;
- }
- function getQuantity(address _user) constant returns (uint _quantity){
- return quantity[_user];
- }
- function changeQuantity(uint _quantity) returns (bool success){
- quantity[msg.sender] = _quantity;
- return true;
- }
- function transfer(address _to, uint _quantity) returns (bool success){
- if (quantity[msg.sender] < _quantity){
- return false;
- }
- owner = _to;
- quantity[msg.sender] -= _quantity;
- quantity[_to] += _quantity;
- Transferred(msg.sender, _to, _quantity);
- return true;
- }
- }
- Filter {
- requestManager:
- RequestManager {
- provider: HttpProvider { host: 'http://localhost:8545', timeout: 0 },
- polls: {},
- timeout: null },
- options:
- { topics: [ '0x6f8b0853f4c56c6a9faec2151763bdc803a695c1ce09b45d3036186c5ae14c47' ],
- from: undefined,
- to: undefined,
- address: '0x570a704dded5379eb21b064cc7750741348e8860',
- fromBlock: '0x0',
- toBlock: 'latest' },
- implementation:
- { newFilter: { [Function: send] request: [Function: bound ], call: [Function: newFilterCall] },
- uninstallFilter: { [Function: send] request: [Function: bound ], call: 'eth_uninstallFilter' },
- getLogs: { [Function: send] request: [Function: bound ], call: 'eth_getFilterLogs' },
- poll: { [Function: send] request: [Function: bound ], call: 'eth_getFilterChanges' } },
- filterId: '0x0b',
- callbacks: [],
- getLogsCallbacks: [],
- pollFilters: [],
- formatter: [Function: outputLogFormatter] }
- let transferEvent = product.Transferred({}, {fromBlock: 0, toBlock: 'latest'})
- transferEvent.get((error, logs) => {
- // we have the logs, now print them
- logs.forEach(log => console.log(log.args))
- })
- { from: '0xc7d748654199d3594239a244d806e51331ca14b5',
- to: '0x3c11b23b4d5adb2d534d262cf83cee773c9b1c0a',
- quantity: { [String: '1'] s: 1, e: 0, c: [ 1 ] } }
- { from: '0xc7d748654199d3594239a244d806e51331ca14b5',
- to: '0x3c11b23b4d5adb2d534d262cf83cee773c9b1c0a',
- quantity: { [String: '3'] s: 1, e: 0, c: [ 3 ] } }
- let events = product.allEvents({fromBlock: 0, toBlock: 'latest'})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement