Solidity Cap Table
Each issuer gets its own CapTable contract, created through a CapTableFactory. The contract stores the issuer, stakeholders, stock classes, positions, and every stock transaction. The issuer’s wallet writes to it from the app, the server key can write to it through the API, and the event poller copies its events into MongoDB.
Roles
| Role | Held by | Can |
|---|---|---|
ADMIN_ROLE | The wallet that called createCapTable, usually the issuer | Grant and revoke roles, adjust authorized shares, and do everything OPERATOR can |
OPERATOR_ROLE | Optional, such as a transfer agent’s server key | Create stakeholders and stock classes, issue and change stock, and link wallets |
| Factory owner | The wallet that deployed the factory | Upgrade the implementation for every cap table on that factory, with no rights inside any cap table |
createCapTable is permissionless. It makes the caller ADMIN, grants OPERATOR to its operator argument unless that’s the zero address, and doesn’t make the caller the factory owner. Admins manage roles with addAdmin, removeAdmin, addOperator, and removeOperator. For how the roles map to local keys, see Three wallets and keys.
To check a role, pass the role’s hash and the wallet:
cast call <CAP_TABLE_ADDRESS> "hasRole(bytes32,address)(bool)" $(cast keccak ADMIN) <WALLET_ADDRESS> --rpc-url https://rpc.plume.orgUse $(cast keccak OPERATOR) for the operator role. The roles are keccak256("ADMIN") and keccak256("OPERATOR"), not OpenZeppelin’s default admin role.
Upgrades
| Contract | Pattern |
|---|---|
CapTableFactory | Owns one UpgradeableBeacon and creates the proxies. |
CapTable | The implementation behind the beacon. |
| Each cap table | A BeaconProxy that reads the implementation from the beacon. |
updateCapTableImplementation, which only the factory owner can call, moves every cap table on the factory to a new implementation in one transaction. To check a factory’s owner and implementation, see Verify the deployment.
Source files
| Contract or library | File | Purpose |
|---|---|---|
CapTable | chain/src/CapTable.sol | Issuer state, roles, and every write. |
CapTableFactory | chain/src/CapTableFactory.sol | Creates proxies and upgrades the beacon. |
ICapTable, ICapTableFactory | chain/src/interfaces/ | Interfaces, with the NatSpec docs. |
Structs | chain/src/lib/Structs.sol | Shared structs. |
StockLib | chain/src/lib/Stock.sol | Stock issuance, transfer, and change logic. |
TxHelper | chain/src/lib/TxHelper.sol | Transaction payloads and the TxCreated event. |
DeleteContext | chain/src/lib/DeleteContext.sol | Removes closed positions. |
Adjustment | chain/src/lib/transactions/Adjustment.sol | Authorized-share changes. |