pragma solidity ^0.5.9;
contract StoredBatches {
struct Batch {
string ipfsHash;
}
event Update(string ipfsHash);
address protocol;
constructor() public {
protocol = msg.sender;
}
modifier onlyProtocol() {
if (msg.sender == protocol) {
_;
}
}
Batch[] public batches;
/// Option to reduce gas usage: https://ethereum.stackexchange.com/questions/17094/how-to-store-ipfs-hash-using-bytes
function registerBatch(string memory _ipfsHash) public onlyProtocol {
batches.push(Batch(_ipfsHash));
emit Update(_ipfsHash);
}
}
{
"compilationTarget": {
"StoredBatches.sol": "StoredBatches"
},
"evmVersion": "petersburg",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"batches","outputs":[{"internalType":"string","name":"ipfsHash","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"_ipfsHash","type":"string"}],"name":"registerBatch","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"ipfsHash","type":"string"}],"name":"Update","type":"event"}]