IStaking
Source: https://github.com/tangle-network/tnt-core/blob/main/src/interfaces/IStaking.sol
IStaking
Abstract interface for staking/shared security protocols
_Implement this to integrate with native staking, Symbiotic, or other staking systems.
Design principles:
- Minimal interface - only what Tangle core needs
- Read-heavy - most operations are queries
- Write-light - only slash() modifies state
- No assumptions about underlying implementation_
Functions
isOperator
function isOperator(address operator) external view returns (bool)Check if an address is a registered operator
Parameters
| Name | Type | Description |
|---|---|---|
| operator | address | The address to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | True if registered as operator |
isOperatorActive
function isOperatorActive(address operator) external view returns (bool)Check if an operator is currently active (not leaving, not slashed out)
Parameters
| Name | Type | Description |
|---|---|---|
| operator | address | The address to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | True if active |
getOperatorStake
function getOperatorStake(address operator) external view returns (uint256)Get an operator’s total stake (self-stake + delegations)
Parameters
| Name | Type | Description |
|---|---|---|
| operator | address | The operator address |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | Total stake amount in native units |
getOperatorSelfStake
function getOperatorSelfStake(address operator) external view returns (uint256)Get an operator’s self-stake only
Parameters
| Name | Type | Description |
|---|---|---|
| operator | address | The operator address |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | Self-stake amount |
getOperatorDelegatedStake
function getOperatorDelegatedStake(address operator) external view returns (uint256)Get total amount delegated to an operator
Parameters
| Name | Type | Description |
|---|---|---|
| operator | address | The operator address |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | Total delegated amount |
getDelegation
function getDelegation(address delegator, address operator) external view returns (uint256)Get a delegator’s delegation to a specific operator
Parameters
| Name | Type | Description |
|---|---|---|
| delegator | address | The delegator address |
| operator | address | The operator address |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | Delegation amount |
getTotalDelegation
function getTotalDelegation(address delegator) external view returns (uint256)Get a delegator’s total delegations across all operators
Parameters
| Name | Type | Description |
|---|---|---|
| delegator | address | The delegator address |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | Total delegated amount |
minOperatorStake
function minOperatorStake() external view returns (uint256)Get minimum stake required to be an operator
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | Minimum stake amount |
meetsStakeRequirement
function meetsStakeRequirement(address operator, uint256 required) external view returns (bool)Check if operator meets a specific stake requirement
Parameters
| Name | Type | Description |
|---|---|---|
| operator | address | The operator address |
| required | uint256 | The required stake amount |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | True if operator has sufficient stake |
slashForBlueprint
function slashForBlueprint(address operator, uint64 blueprintId, uint64 serviceId, uint256 amount, bytes32 evidence) external returns (uint256 actualSlashed)Slash an operator’s stake for a specific blueprint
Only affects delegators exposed to this blueprint (All mode + Fixed mode who selected it)
Parameters
| Name | Type | Description |
|---|---|---|
| operator | address | The operator to slash |
| blueprintId | uint64 | The blueprint where violation occurred |
| serviceId | uint64 | The service where violation occurred |
| amount | uint256 | Amount to slash |
| evidence | bytes32 | Evidence hash (IPFS or other reference) |
Return Values
| Name | Type | Description |
|---|---|---|
| actualSlashed | uint256 | The actual amount slashed (may be less if insufficient stake) |
slashForService
function slashForService(address operator, uint64 blueprintId, uint64 serviceId, struct Types.AssetSecurityCommitment[] commitments, uint256 amount, bytes32 evidence) external returns (uint256 actualSlashed)Slash an operator for a specific service, only slashing committed assets
Only slashes assets the operator committed to this service, proportionally
Parameters
| Name | Type | Description |
|---|---|---|
| operator | address | The operator to slash |
| blueprintId | uint64 | The blueprint where violation occurred |
| serviceId | uint64 | The service where violation occurred |
| commitments | struct Types.AssetSecurityCommitment[] | The operator’s asset security commitments for this service |
| amount | uint256 | Amount to slash |
| evidence | bytes32 | Evidence hash (IPFS or other reference) |
Return Values
| Name | Type | Description |
|---|---|---|
| actualSlashed | uint256 | The actual amount slashed (may be less if insufficient committed stake) |
slash
function slash(address operator, uint64 serviceId, uint256 amount, bytes32 evidence) external returns (uint256 actualSlashed)Slash an operator’s stake (legacy - slashes all delegators)
Only callable by authorized slashers (e.g., Tangle core contract)
Parameters
| Name | Type | Description |
|---|---|---|
| operator | address | The operator to slash |
| serviceId | uint64 | The service where violation occurred |
| amount | uint256 | Amount to slash |
| evidence | bytes32 | Evidence hash (IPFS or other reference) |
Return Values
| Name | Type | Description |
|---|---|---|
| actualSlashed | uint256 | The actual amount slashed (may be less if insufficient stake) |
isSlasher
function isSlasher(address account) external view returns (bool)Check if an address is authorized to call slash()
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The address to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | True if authorized |
Events
OperatorSlashed
event OperatorSlashed(address operator, uint64 serviceId, uint256 amount, bytes32 evidence)Emitted when an operator is slashed