Protocol SpecificationSolidity Reference

Solidity Reference

First-party Solidity only: chain/src. Vendor code under chain/lib is out of scope.

CapTable writes

CapTable.sol stores issuer, stock class, stakeholder, wallet, active position, and transaction state.

FunctionAccessInputsEffectAPI
initializeInitializerIssuer ID, name, authorized shares, admin, operator.Sets roles and issuer; emits IssuerCreated.Factory/frontend deploy.
mintSharesAuthorizedOperatorInitialShares.Seeds issued/authorized counts.OCF import.
mintActivePositionsOperatorStakeholder, security, class, quantity, price, timestamp arrays.Seeds positions; emits ActivePositionMinted.OCF import.
createStakeholderOperatorID, type, relationship.Adds stakeholder; emits StakeholderCreated.POST /stakeholder/create
createStockClassOperatorID, type, price, authorized shares.Adds stock class; emits StockClassCreated.POST /stock-class/create
createStockLegendTemplateOperatorLegend ID.Adds onchain legend ID.Direct contract call.
addWalletToStakeholderOperatorStakeholder ID, wallet.Maps wallet; emits WalletAdded.POST /stakeholder/add-wallet
removeWalletFromStakeholderOperatorStakeholder ID, wallet.Deletes mapping; emits WalletRemoved.POST /stakeholder/remove-wallet
issueStockOperatorStockIssuanceParams.Adds position, increments nonce and issued shares.POST /transactions/issuance/stock
transferStockOperatorStockTransferParams.Moves shares; may create balance/resulting issuances.POST /transactions/transfer/stock
cancelStockOperatorStockParams, quantity.Cancels shares; may create balance issuance.POST /transactions/cancel/stock
retractStockIssuanceOperatorStockParams.Records retraction; removes active position.POST /transactions/retract/stock
reissueStockOperatorStockParams, resulting IDs.Records reissue; removes original position.POST /transactions/reissue/stock
repurchaseStockOperatorStockParams, quantity, price.Records repurchase; subtracts issued shares.POST /transactions/repurchase/stock
acceptStockOperatorStakeholder, class, security, comments.Records acceptance only.POST /transactions/accept/stock
adjustIssuerAuthorizedSharesAdminNew authorized shares, comments, approval dates.Updates issuer authorized shares.POST /transactions/adjust/issuer/authorized-shares
adjustStockClassAuthorizedSharesAdminClass ID, new authorized shares, comments, approval dates.Updates class authorized shares.POST /transactions/adjust/stock-class/authorized-shares
addAdmin / removeAdminAdminAddress.Grants/revokes admin.Direct contract call.
addOperator / removeOperatorAdminAddress.Grants/revokes operator.Direct contract call.

CapTable reads

FunctionReturns
transactions(uint256)Encoded transaction bytes.
getTransactionsCountTransaction count.
getTotalActiveSecuritiesCountActive security count.
getStakeholderByIdStakeholder ID, type, relationship.
getStockClassByIdClass ID, type, price, issued, authorized.
getStakeholderIdByWalletStakeholder ID.
getTotalNumberOfStakeholdersStakeholder count.
getTotalNumberOfStockClassesStock class count.
getActivePositionClass ID, quantity, price, timestamp.
getAveragePositionQuantity-price sum, quantity, latest timestamp.

CapTable events and errors

KindNames
EventsIssuerCreated, StakeholderCreated, StockClassCreated, StockLegendTemplateCreated, WalletAdded, WalletRemoved, SharesAuthorizedMinted, ActivePositionMinted
ErrorsStakeholderAlreadyExists, StockClassAlreadyExists, InvalidWallet, NoStakeholder, InvalidStockClass, NoIssuanceFound, WalletAlreadyExists, NoActivePositionFound

CapTableFactory

FunctionAccessEffect
constructorDeploy-timeStores implementation and deploys the beacon.
createCapTablePublicDeploys a beacon proxy, initializes it, stores it, emits CapTableCreated, returns proxy address.
updateCapTableImplementationOwnerUpdates the beacon implementation; emits CapTableImplementationUpdated.
getCapTableCountPublic viewReturns created proxy count.

Interfaces

InterfaceExposes
ICapTableRoles, public mappings, initializer, lifecycle writes, admin writes, reads.
ICapTableFactoryCreate, upgrade, count, factory events.

Libraries

LibraryFunctionPurpose
StockLibcreateIssuanceCreate issuance and active position.
StockLibcreateTransferMove quantity across transferor securities.
StockLibcreateCancellationCancel quantity; maybe create balance issuance.
StockLibcreateReissuanceRecord reissue; remove original security.
StockLibcreateRepurchaseRecord repurchase; maybe create balance issuance.
StockLibcreateRetractionRecord retraction; remove original security.
StockLibcreateAcceptanceRecord acceptance only.
TxHelpercreateTxStore encoded tx and emit TxCreated.
TxHelpergenerateDeterministicUniqueIDDerive bytes16 IDs.
TxHelpercreate*Struct / adjust*Build encoded transaction payload structs.
DeleteContextdeleteActivePositionDelete one active position.
DeleteContextdeleteActiveSecurityIdsByStockClassRemove one security ID from a class list.
AdjustmentadjustIssuerAuthorizedSharesRecord and apply issuer authorized-share changes.
AdjustmentadjustStockClassAuthorizedSharesRecord and apply class authorized-share changes.

StockLib errors: InsufficientShares, InvalidQuantityOrPrice, UnverifiedBuyer, ActivePositionNotFound.

TxType: issuer/class authorized-share adjustments, stock acceptance, cancellation, issuance, reissuance, repurchase, retraction, transfer.

Struct fields live in Structs Library. Lifecycle notes live in Stock Functions.

⚠️

Before public deployment, review role custody, factory ownership, and upgrade custody.