Skip to main content

Core Components

note

Prerequisites: Before reading this, you should have chosen a deployment modality and understand basic Solidity concepts.

Audience: Relevant for all developers.

Usage Context: Before starting any development on ISBE.

Core Components are the fundamental capabilities automatically inherited by all contracts deployed on ISBE.

Overview​

The Core groups the system's base functionalities:

  • Initialization: Secure pattern for Diamond proxies.
  • Introspection: Detection of supported interfaces (ERC165).
  • Access Control: RBAC system integrated with DIDs.
  • Ownership: Contract owner management.
  • Pausability: Emergency pause capability.
  • Utilities: Validations and access to blockchain context.

All these components are aggregated in DidDocumentDetailedInternal, which acts as a universal base class.

DidDocumentDetailedInternal​

DidDocumentDetailedInternal aggregates all Core capabilities. All ISBE contracts inherit from DidDocumentDetailedInternal.

contract MyUseCase is DidDocumentDetailedInternal {
// Your contract automatically inherits all Core capabilities
}

Proxy Initialization​

ISBE uses the Diamond Proxy pattern (EIP-2535). Proxies cannot use constructors, so the Core provides secure initialization.

bytes32 constant BUSINESS_ID = keccak256("MyToken.business.id");

function initialize(string memory name)
external
initializer(BUSINESS_ID)
{
// Executes only once per facet
}

This BUSINESS_ID will be used later throughout the facet's lifecycle.

The initializer(_businessID) modifier ensures single execution and prevents re-initializations.

Interface Introspection​

Implements the ERC165 standard for interface detection. It allows querying what capabilities a contract supports:

bool supportsERC20 = contract.supportsInterface(type(IERC20).interfaceId);

Contracts automatically register their implemented interfaces (ERC20, ERC721, AccessControl, etc.).

Access Control (RBAC)​

Role-based access control system integrated with decentralized identities (DIDs).

Function Protection:

modifier onlyRole(bytes32 _role) {
_checkRole(_role);
_;
}

Role Management:

// Grant/revoke roles by address (EOA)
function _grantRole(bytes32 role, address account) internal;
function _revokeRole(bytes32 role, address account) internal;

// Grant/revoke roles by DID
function _grantDidRole(bytes32 role, bytes32 did) internal;
function _revokeDidRole(bytes32 role, bytes32 did) internal;

// Verify roles
function _hasRole(bytes32 role, address account) internal view returns (bool);
function _hasDidRole(bytes32 role, bytes32 did) internal view returns (bool);

Usage Example:

contract MyUseCase is DidDocumentDetailedInternal {
bytes32 public constant OPERATOR_ROLE = keccak256("OPERADOR_ROLE");

function operate() external onlyRole(OPERATOR_ROLE) {
// Only operators can execute
}
}

Note: Initial roles are configured during proxy deployment (roles and members parameters in deployUseCase). Subsequent updates are performed via AccessControlFacet (grantRole/revokeRole).

DID Integration: Roles can be assigned to both Ethereum addresses and DIDs. If an address has an associated DID, both are validated automatically.

Ownership Management​

Single contract ownership mechanism. Only the owner can execute protected functions.

modifier onlyOwner() {
_checkOwner();
_;
}

Functions:

function _owner() internal view returns (address);
function _transferOwnership(address newOwner) internal;

Pausability​

Ability to pause all contract operations in case of emergency.

modifier whenNotPaused() {
_requireNotPaused();
_;
}

Functions:

function _paused() internal view returns (bool);
function _requireNotPaused() internal view;

Example:

function transfer(address to, uint256 amount) 
external
whenNotPaused
returns (bool)
{
// Blocked if the contract is paused
}

All ISBE templates implement automatic pausability in critical operations.

Utilities and Validations​

Blockchain context functions and common validations.

Blockchain Context:

function _blockTimestamp() internal view returns (uint256);
function _blockChainId() internal view returns (uint256);
function _msgSender() internal view returns (address);
function _msgSig() internal view returns (bytes4);

Validations:

// Content validations
function _checkAddressIsNotZero(address addr) internal pure;
function _checkBytes32IsNotZero(bytes32 hash) internal pure;
function _checkEmptyBytes(bytes memory code) internal pure;
function _checkEmptyString(string memory str) internal pure;
function _checkUintIsNotZero(uint256 value) internal pure;

// Comparisons
function _equalStrings(string memory a, string memory b) internal pure returns (bool);
function _equalBytes(bytes memory a, bytes memory b) internal pure returns (bool);

// Temporal validation
function _checkValidDates(uint256 before, uint256 after) internal pure;

Core Components Summary​

ComponentCapability
DidDocumentDetailedInternalUniversal base class
Initializationinitializer(_businessID)
IntrospectionsupportsInterface()
Access ControlonlyRole(), DID integration
OwnershiponlyOwner()
PausabilitywhenNotPaused()
UtilitiesValidations and blockchain context

By inheriting from DidDocumentDetailedInternal, all these components are automatically available.


Other technical reference topics: