BuildapireferenceIStaking

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
NameTypeDescription
operatoraddressThe address to check
Return Values
NameTypeDescription
[0]boolTrue 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
NameTypeDescription
operatoraddressThe address to check
Return Values
NameTypeDescription
[0]boolTrue if active

getOperatorStake

function getOperatorStake(address operator) external view returns (uint256)

Get an operator’s total stake (self-stake + delegations)

Parameters
NameTypeDescription
operatoraddressThe operator address
Return Values
NameTypeDescription
[0]uint256Total stake amount in native units

getOperatorSelfStake

function getOperatorSelfStake(address operator) external view returns (uint256)

Get an operator’s self-stake only

Parameters
NameTypeDescription
operatoraddressThe operator address
Return Values
NameTypeDescription
[0]uint256Self-stake amount

getOperatorDelegatedStake

function getOperatorDelegatedStake(address operator) external view returns (uint256)

Get total amount delegated to an operator

Parameters
NameTypeDescription
operatoraddressThe operator address
Return Values
NameTypeDescription
[0]uint256Total delegated amount

getDelegation

function getDelegation(address delegator, address operator) external view returns (uint256)

Get a delegator’s delegation to a specific operator

Parameters
NameTypeDescription
delegatoraddressThe delegator address
operatoraddressThe operator address
Return Values
NameTypeDescription
[0]uint256Delegation amount

getTotalDelegation

function getTotalDelegation(address delegator) external view returns (uint256)

Get a delegator’s total delegations across all operators

Parameters
NameTypeDescription
delegatoraddressThe delegator address
Return Values
NameTypeDescription
[0]uint256Total delegated amount

minOperatorStake

function minOperatorStake() external view returns (uint256)

Get minimum stake required to be an operator

Return Values
NameTypeDescription
[0]uint256Minimum stake amount

meetsStakeRequirement

function meetsStakeRequirement(address operator, uint256 required) external view returns (bool)

Check if operator meets a specific stake requirement

Parameters
NameTypeDescription
operatoraddressThe operator address
requireduint256The required stake amount
Return Values
NameTypeDescription
[0]boolTrue 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
NameTypeDescription
operatoraddressThe operator to slash
blueprintIduint64The blueprint where violation occurred
serviceIduint64The service where violation occurred
amountuint256Amount to slash
evidencebytes32Evidence hash (IPFS or other reference)
Return Values
NameTypeDescription
actualSlasheduint256The 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
NameTypeDescription
operatoraddressThe operator to slash
blueprintIduint64The blueprint where violation occurred
serviceIduint64The service where violation occurred
commitmentsstruct Types.AssetSecurityCommitment[]The operator’s asset security commitments for this service
amountuint256Amount to slash
evidencebytes32Evidence hash (IPFS or other reference)
Return Values
NameTypeDescription
actualSlasheduint256The 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
NameTypeDescription
operatoraddressThe operator to slash
serviceIduint64The service where violation occurred
amountuint256Amount to slash
evidencebytes32Evidence hash (IPFS or other reference)
Return Values
NameTypeDescription
actualSlasheduint256The 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
NameTypeDescription
accountaddressThe address to check
Return Values
NameTypeDescription
[0]boolTrue if authorized

Events

OperatorSlashed

event OperatorSlashed(address operator, uint64 serviceId, uint256 amount, bytes32 evidence)

Emitted when an operator is slashed