Contract Address Details
0x951c68F7c59c355581Efb8381C2f1B3cD1CF23E2
Product
>=
4
Incoming Transactions
Last Balance Update: Block #2494964
Created by 0x45bb–cc14f6
at
0x8af9–df0c45
Balance
0 Ether
Fetching tokens...
- Contract name:
- Product
- Optimization enabled
- false
- Compiler version
- v0.5.4+commit.9549d8ff
Contract source code
/*** Submitted for verification at blockscout.com on 2023-12-19 22:25:48.975583Z*/pragma solidity ^0.5.4;contract Product { address private owner; string public productString; string public productName; /*作物批號*/ string public farm; /*農場*/ bytes32 public latestHash; event hash( bytes32 latestHash ); constructor(string memory _farm, string memory _productName) public{ owner = msg.sender; farm = _farm; productName = _productName; productString = string(abi.encodePacked('farm=', farm, '&product=', productName)); latestHash = keccak256(bytes(productString)); emit hash(latestHash); } function getProductString() public view returns(string memory) { return productString; } struct row { uint64 timestamp; /*UNIX時間格式*/ string task; /*工作項目*/ string location; /*地點*/ string tool; /*工具*/ string tool_type; /*工具類別*/ string remark; /*備註*/ bytes32 prev_hash; /*前一筆資料的hash*/ } function rowToEncode(row memory x) private pure returns(bytes memory) { uint16 version = 1; bytes memory encoded_row = abi.encodePacked( abi.encodePacked( version, stringToSelector('timestamp'), abi.encodePacked(x.timestamp), stringToSelector('task'), keccak256(bytes(x.task)), stringToSelector('location'), keccak256(bytes(x.location)) ), abi.encodePacked( stringToSelector('tool'), keccak256(bytes(x.tool)), stringToSelector('tool_type'), keccak256(bytes(x.tool_type)), stringToSelector('remark'), keccak256(bytes(x.remark)) ), x.prev_hash ); return encoded_row; } function stringToSelector(string memory x) private pure returns(bytes4) { return(bytes4(keccak256(bytes(x)))); } function addRow ( uint64 _timestampe, string calldata _task, string calldata _location, string calldata _tool, string calldata _tool_type, string calldata _remark ) external { require(msg.sender == owner); row memory newRow = row(_timestampe, _task, _location, _tool, _tool_type, _remark, latestHash); latestHash = keccak256(rowToEncode(newRow)); emit hash(latestHash); } }
Contract ABI
[{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"string","name":""}],"name":"farm","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"addRow","inputs":[{"type":"uint64","name":"_timestampe"},{"type":"string","name":"_task"},{"type":"string","name":"_location"},{"type":"string","name":"_tool"},{"type":"string","name":"_tool_type"},{"type":"string","name":"_remark"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":""}],"name":"latestHash","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"string","name":""}],"name":"productName","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"string","name":""}],"name":"productString","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"string","name":""}],"name":"getProductString","inputs":[],"constant":true},{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"string","name":"_farm"},{"type":"string","name":"_productName"}]},{"type":"event","name":"hash","inputs":[{"type":"bytes32","name":"latestHash","indexed":false}],"anonymous":false}]
Contract Byte Code
0x608060405234801561001057600080fd5b506004361061007f576000357c01000000000000000000000000000000000000000000000000000000009004806336e9332d1461008457806337fd376f146101075780636f17d258146102e85780637f7650eb146103065780638e2e9cda1461038957806395b20d221461040c575b600080fd5b61008c61048f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100cc5780820151818401526020810190506100b1565b50505050905090810190601f1680156100f95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102e6600480360360c081101561011d57600080fd5b81019080803567ffffffffffffffff1690602001909291908035906020019064010000000081111561014e57600080fd5b82018360208201111561016057600080fd5b8035906020019184600183028401116401000000008311171561018257600080fd5b9091929391929390803590602001906401000000008111156101a357600080fd5b8201836020820111156101b557600080fd5b803590602001918460018302840111640100000000831117156101d757600080fd5b9091929391929390803590602001906401000000008111156101f857600080fd5b82018360208201111561020a57600080fd5b8035906020019184600183028401116401000000008311171561022c57600080fd5b90919293919293908035906020019064010000000081111561024d57600080fd5b82018360208201111561025f57600080fd5b8035906020019184600183028401116401000000008311171561028157600080fd5b9091929391929390803590602001906401000000008111156102a257600080fd5b8201836020820111156102b457600080fd5b803590602001918460018302840111640100000000831117156102d657600080fd5b909192939192939050505061052d565b005b6102f0610783565b6040518082815260200191505060405180910390f35b61030e610789565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561034e578082015181840152602081019050610333565b50505050905090810190601f16801561037b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610391610827565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d15780820151818401526020810190506103b6565b50505050905090810190601f1680156103fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104146108c5565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610454578082015181840152602081019050610439565b50505050905090810190601f1680156104815780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105255780601f106104fa57610100808354040283529160200191610525565b820191906000526020600020905b81548152906001019060200180831161050857829003601f168201915b505050505081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561058857600080fd5b610590610ed3565b60e0604051908101604052808d67ffffffffffffffff1681526020018c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505081526020018a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050815260200188888080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050815260200186868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050815260200184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508152602001600454815250905061072f81610967565b805190602001206004819055507fd8389dc559aa0a8c6ffecc778865159cea397fa8c1cba3db9a4d0a8be374d6626004546040518082815260200191505060405180910390a1505050505050505050505050565b60045481565b60028054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561081f5780601f106107f45761010080835404028352916020019161081f565b820191906000526020600020905b81548152906001019060200180831161080257829003601f168201915b505050505081565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108bd5780601f10610892576101008083540402835291602001916108bd565b820191906000526020600020905b8154815290600101906020018083116108a057829003601f168201915b505050505081565b606060018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561095d5780601f106109325761010080835404028352916020019161095d565b820191906000526020600020905b81548152906001019060200180831161094057829003601f168201915b5050505050905090565b60606000600190506060816109b06040805190810160405280600981526020017f74696d657374616d700000000000000000000000000000000000000000000000815250610ec2565b8560000151604051602001808267ffffffffffffffff1667ffffffffffffffff167801000000000000000000000000000000000000000000000000028152600801915050604051602081830303815290604052610a416040805190810160405280600481526020017f7461736b00000000000000000000000000000000000000000000000000000000815250610ec2565b876020015180519060200120610a8b6040805190810160405280600881526020017f6c6f636174696f6e000000000000000000000000000000000000000000000000815250610ec2565b896040015180519060200120604051602001808861ffff1661ffff167e01000000000000000000000000000000000000000000000000000000000000028152600201877bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260040186805190602001908083835b602083101515610b425780518252602082019150602081019050602083039250610b1d565b6001836020036101000a038019825116818451168082178552505050505050905001857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152600401848152602001837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152600401828152602001975050505050505050604051602081830303815290604052610c4e6040805190810160405280600481526020017f746f6f6c00000000000000000000000000000000000000000000000000000000815250610ec2565b856060015180519060200120610c986040805190810160405280600981526020017f746f6f6c5f747970650000000000000000000000000000000000000000000000815250610ec2565b876080015180519060200120610ce26040805190810160405280600681526020017f72656d61726b0000000000000000000000000000000000000000000000000000815250610ec2565b8960a001518051906020012060405160200180877bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152600401868152602001857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152600401848152602001837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260040182815260200196505050505050506040516020818303038152906040528560c001516040516020018084805190602001908083835b602083101515610e275780518252602082019150602081019050602083039250610e02565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b602083101515610e7a5780518252602082019150602081019050602083039250610e55565b6001836020036101000a038019825116818451168082178552505050505050905001828152602001935050505060405160208183030381529060405290508092505050919050565b600081805190602001209050919050565b60e060405190810160405280600067ffffffffffffffff168152602001606081526020016060815260200160608152602001606081526020016060815260200160008019168152509056fea165627a7a7230582002cbe579990083f87868eedffb3d733fa1ebe1324c6d4ebc1d6c96abcb854f280029