Skip to main content

ComplianceFacet

Asset Tokenization Studio Team

ComplianceFacet

Diamond facet exposing transfer-eligibility checks and compliance contract management.

Registers four selectors: canTransfer, canTransferFrom, setCompliance, and compliance. Inherits business logic from the Compliance abstract contract.

Methods​

canTransfer​

function canTransfer(address _to, uint256 _value, bytes _data) external view returns (bool, bytes1, bytes32)

Checks if a transfer can be executed

Only available when multi-partition mode is disabled. Uses msg.sender as sender.

Parameters​

NameTypeDescription
_toaddressThe recipient address
_valueuint256The amount of tokens to transfer
_databytesAdditional data for the transfer check

Returns​

NameTypeDescription
_0boolbool True if the transfer can be executed
_1bytes1bytes1 EIP1066 status code indicating the result
_2bytes32bytes32 Additional reason data for the result

canTransferFrom​

function canTransferFrom(address _from, address _to, uint256 _value, bytes _data) external view returns (bool, bytes1, bytes32)

Checks if a transferFrom can be executed

Only available when multi-partition mode is disabled.

Parameters​

NameTypeDescription
_fromaddressThe sender address
_toaddressThe recipient address
_valueuint256The amount of tokens to transfer
_databytesAdditional data for the transfer check

Returns​

NameTypeDescription
_0boolbool True if the transfer can be executed
_1bytes1bytes1 EIP1066 status code indicating the result
_2bytes32bytes32 Additional reason data for the result

compliance​

function compliance() external view returns (contract ICompliance)

Returns the address of the compliance contract

Returns​

NameTypeDescription
_0contract IComplianceICompliance The compliance contract

getStaticFunctionSelectors​

function getStaticFunctionSelectors() external pure returns (bytes4[])

Gets all function selectors of a facet

Returns​

NameTypeDescription
_0bytes4[]Face functions selectors

getStaticInterfaceIds​

function getStaticInterfaceIds() external pure returns (bytes4[])

Gets all interfaces ids of a facet.

Returns​

NameTypeDescription
_0bytes4[]Face interface ids

getStaticResolverKey​

function getStaticResolverKey() external pure returns (bytes32 staticResolverKey_)

Gets the static resolver key

Returns​

NameTypeDescription
staticResolverKey_bytes32Static resolver key

initializeCompliance​

function initializeCompliance(address _compliance) external nonpayable

Initialises the compliance capability on the token and wires the compliance contract.

Wires the compliance contract address, marks the compliance facet as ready, and emits ComplianceInitialized. One-shot is enforced by onlyFacetNotRegistered.

Parameters​

NameTypeDescription
_complianceaddressAddress of the compliance contract that authorises transfers.

setCompliance​

function setCompliance(address _compliance) external nonpayable

Sets the compliance contract address

Requires an operational, activated, unpaused token and TREX_OWNER_ROLE. Emits ComplianceAdded so off-chain observers can track which compliance contract was authoritative at any point in time.

Parameters​

NameTypeDescription
_complianceaddressThe address of the new compliance contract

Events​

ComplianceAdded​

event ComplianceAdded(address indexed compliance)

Emitted when the compliance contract address is updated.

Parameters​

NameTypeDescription
compliance indexedaddressAddress of the newly wired compliance contract.

ComplianceInitialized​

event ComplianceInitialized(address compliance)

Emitted once when the compliance capability is initialised on a token.

Fires exclusively from initializeCompliance.

Parameters​

NameTypeDescription
complianceaddressThe compliance contract address wired at initialisation.

Errors​

AccountHasNoRole​

error AccountHasNoRole(address account, bytes32 role)

Thrown when an account does not hold a required role.

Parameters​

NameTypeDescription
accountaddressThe account that lacks the role.
rolebytes32The role that is not held.

AssetNotOperational​

error AssetNotOperational(bytes32 configId, uint256 versionId)

Raised by InitializerStorageWrapper.checkOperational (and the related isConfigVersionOperational helper) when an operation is attempted on a configuration version that has not yet been marked operational.

Parameters​

NameTypeDescription
configIdbytes32Resolver-proxy configuration whose operational status was checked.
versionIduint256Configuration version whose operational status was checked.

Deactivated​

error Deactivated()

Thrown when an operation guarded by onlyActivated is attempted on a token whose deactivation flag has already been set.

FacetAlreadyRegistered​

error FacetAlreadyRegistered(bytes32 facetId, uint256 lastVersion)

Raised when an initialiser tries to register a facet that already has a non-zero last registered version (i.e. the facet is being re-initialised on a fresh install).

Parameters​

NameTypeDescription
facetIdbytes32Identifier of the offending facet.
lastVersionuint256Last version recorded for that facet at the time of the check.

IsPaused​

error IsPaused()

Thrown when an operation that requires the token to be unpaused is attempted while the token is paused (own flag or any external pause contract).

NotAllowedInMultiPartitionMode​

error NotAllowedInMultiPartitionMode()

Thrown when a single-partition operation is attempted on a multi-partition token.

UnrecognizedResolverProxyVersion​

error UnrecognizedResolverProxyVersion(bytes8 _resolverProxyVersion)

Thrown when the provided proxy version does not match any BLR compatible standard.

Parameters​

NameTypeDescription
_resolverProxyVersionbytes8proxy version that is not compatible with the BLR.

WalletRecovered​

error WalletRecovered()

Thrown when attempting to recover a wallet that has already been recovered.