Contract detail
Foreman
Live Robinhood Chain account facts for 0xffdedd3a…bd01f83f with at least 891 observed transactions. The history total is updating as indexing continues.
- Address type
- Smart contract
- Transactions
- 891+ observed
- First indexed block
- #94321848
- Latest indexed block
- #126614514
- History coverage
- Recent activity available; total is catching up
- Emitted events
- 884
- Verification
- Verified
- Compiler
- 0.8.24+commit.e11b9ed9
- Verification match
- exact
- Creation transaction
- 0x0f7e556f…fac970d3
- Created at block
- #94321848
- Language
- Solidity
- EVM version
- cancun
- License
- MIT
- Compiler optimization
- Enabled · 200 runs
- Deployed bytecode hash
- 0xc071e382fa70f9b3040fb6f81c04e468bf526cd0a4ce23211f1da18594939861
Related activity
Transactions
Verified contract
Contract source code
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
interface IWorkers {
function ownerOf(uint256 tokenId) external view returns (address);
function clockIn(uint256 tokenId) external;
function clockOut(uint256 tokenId) external;
}
/// @title Foreman: clock in (or out) every Worker you hold in one transaction.
/// @notice Holder approves this contract once, then calls clockInAll / clockOutAll.
/// It can only call clockIn and clockOut, only on tokens the caller owns.
/// No transfer, owner, admin, upgrade or withdraw code. Revoke any time with
/// setApprovalForAll(foreman, false) on the Workers contract.
contract Foreman {
IWorkers public immutable workers;
event Shift(address indexed holder, bool indexed clockingIn, uint256 done, uint256 skipped);
error NoTokens();
constructor(IWorkers workers_) {
workers = workers_;
}
function clockInAll(uint256[] calldata tokenIds) external returns (uint256 done) {
return _run(tokenIds, true);
}
function clockOutAll(uint256[] calldata tokenIds) external returns (uint256 done) {
return _run(tokenIds, false);
}
function _run(uint256[] calldata tokenIds, bool clockingIn) private returns (uint256 done) {
uint256 n = tokenIds.length;
if (n == 0) revert NoTokens();
for (uint256 i; i < n; ++i) {
uint256 id = tokenIds[i];
if (!_owns(msg.sender, id)) continue;
if (clockingIn) {
try workers.clockIn(id) { ++done; } catch {}
} else {
try workers.clockOut(id) { ++done; } catch {}
}
}
emit Shift(msg.sender, clockingIn, done, n - done);
}
function _owns(address who, uint256 id) private view returns (bool) {
try workers.ownerOf(id) returns (address o) {
return o == who;
} catch {
return false;
}
}
}