// SPDX-License-Identifier: CC0-1.0
pragmasolidity0.8.17;/**
* @title DLT token standard interface
* @dev Interface for any contract that wants to implement the DLT standard
*/interfaceIDLT{/**
* @dev MUST emit when `subId` token is transferred from `sender` to `recipient`
* @param sender is the address of the previous holder whose balance is decreased
* @param recipient is the address of the new holder whose balance is increased
* @param mainId is the main token type ID to be transferred
* @param subId is the token subtype ID to be transferred
* @param amount is the amount to be transferred of the token subtype
*/eventTransfer(addressindexedsender,addressindexedrecipient,uint256indexedmainId,uint256subId,uint256amount);/**
* @dev MUST emit when `subIds` token array is transferred from `sender` to `recipient`
* @param sender is the address of the previous holder whose balance is decreased
* @param recipient is the address of the new holder whose balance is increased
* @param mainIds is the main token type ID array to be transferred
* @param subIds is the token subtype ID array to be transferred
* @param amounts is the amount array to be transferred of the token subtype
*/eventTransferBatch(addressindexedsender,addressindexedrecipient,uint256[]mainIds,uint256[]subIds,uint256[]amounts);/**
* @dev MUST emit when `owner` enables `operator` to manage the `subId` token
* @param owner is the address of the token owner
* @param operator is the authorized address to manage the allocated amount for an owner address
* @param mainId is the main token type ID to be approved
* @param subId is the token subtype ID to be approved
* @param amount is the amount to be approved of the token subtype
*/eventApproval(addressindexedowner,addressindexedoperator,uint256mainId,uint256subId,uint256amount);/**
* @dev MUST emit when `owner` enables or disables (`approved`) `operator` to manage all of its assets
* @param owner is the address of the token owner
* @param operator is the authorized address to manage all tokens for an owner address
* @param approved true if the operator is approved, false to revoke approval
*/eventApprovalForAll(addressindexedowner,addressindexedoperator,boolapproved);/**
* @dev MUST emit when the URI is updated for a main token type ID.
* URIs are defined in RFC 3986.
* The URI MUST point to a JSON file that conforms to the "DLT Metadata URI JSON Schema".
* @param oldValue is the old URI value
* @param newValue is the new URI value
* @param mainId is the main token type ID
*/eventURI(stringoldValue,stringnewValue,uint256indexedmainId);/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any subId owned by the caller.
* The `operator` MUST NOT be the caller.
* MUST emit an {ApprovalForAll} event.
* @param operator is the authorized address to manage all tokens for an owner address
* @param approved true if the operator is approved, false to revoke approval
*/functionsetApprovalForAll(addressoperator,boolapproved)external;/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
* MUST revert if `sender` or `recipient` is the zero address.
* MUST revert if balance of holder for token `subId` is lower than the `amount` sent.
* MUST emit a {Transfer} event.
* @param sender is the address of the previous holder whose balance is decreased
* @param recipient is the address of the new holder whose balance is increased
* @param mainId is the main token type ID to be transferred
* @param subId is the token subtype ID to be transferred
* @param amount is the amount to be transferred of the token subtype
* @param data is additional data with no specified format
* @return True if the operation succeeded, false if operation failed
*/functionsafeTransferFrom(addresssender,addressrecipient,uint256mainId,uint256subId,uint256amount,bytescalldatadata)externalreturns(bool);/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
* The `operator` MUST NOT be the caller.
* MUST revert if `operator` is the zero address.
* MUST emit an {Approval} event.
* @param operator is the authorized address to manage tokens for an owner address
* @param mainId is the main token type ID to be approved
* @param subId is the token subtype ID to be approved
* @param amount is the amount to be approved of the token subtype
* @return True if the operation succeeded, false if operation failed
*/functionapprove(addressoperator,uint256mainId,uint256subId,uint256amount)externalreturns(bool);/**
* @notice Get the token with a particular subId balance of an `account`
* @param account is the address of the token holder
* @param mainId is the main token type ID
* @param subId is the token subtype ID
* @return The amount of tokens owned by `account` in subId
*/functionsubBalanceOf(addressaccount,uint256mainId,uint256subId)externalviewreturns(uint256);/**
* @notice Get the tokens with a particular subIds balance of an `accounts` array
* @param accounts is the address array of the token holder
* @param mainIds is the main token type ID array
* @param subIds is the token subtype ID array
* @return The amount of tokens owned by `accounts` in subIds
*/functionbalanceOfBatch(address[]calldataaccounts,uint256[]calldatamainIds,uint256[]calldatasubIds)externalviewreturns(uint256[]calldata);/**
* @notice Get the allowance allocated to an `operator`
* @dev This value changes when {approve} or {transferFrom} are called
* @param owner is the address of the token owner
* @param operator is the authorized address to manage assets for an owner address
* @param mainId is the main token type ID
* @param subId is the token subtype ID
* @return The remaining number of tokens that `operator` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*/functionallowance(addressowner,addressoperator,uint256mainId,uint256subId)externalviewreturns(uint256);/**
* @notice Get the approval status of an `operator` to manage assets
* @param owner is the address of the token owner
* @param operator is the authorized address to manage assets for an owner address
* @return True if the `operator` is allowed to manage all of the assets of `owner`, false if approval is revoked
* See {setApprovalForAll}
*/functionisApprovedForAll(addressowner,addressoperator)externalviewreturns(bool);}
DLTReceiver 接口
智能合约必须实现 DLTReceiver 接口中的所有函数才能接受转账。
// SPDX-License-Identifier: CC0-1.0
pragmasolidity0.8.17;/**
* @title DLT token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from DLT asset contracts.
*/interfaceIDLTReceiver{/**
* @notice Handle the receipt of a single DLT token type.
* @dev Whenever an {DLT} `subId` token is transferred to this contract via {IDLT-safeTransferFrom}
* by `operator` from `sender`, this function is called.
* MUST return its Solidity selector to confirm the token transfer.
* MUST revert if any other value is returned or the interface is not implemented by the recipient.
* The selector can be obtained in Solidity with `IDLTReceiver.onDLTReceived.selector`.
* @param operator is the address which initiated the transfer
* @param from is the address which previously owned the token
* @param mainId is the main token type ID being transferred
* @param subId subId is the token subtype ID being transferred
* @param amount is the amount of tokens being transferred
* @param data is additional data with no specified format
* @return `IDLTReceiver.onDLTReceived.selector`
*/functiononDLTReceived(addressoperator,addressfrom,uint256mainId,uint256subId,uint256amount,bytescalldatadata)externalreturns(bytes4);/**
* @notice Handle the receipts of a DLT token type array.
* @dev Whenever an {DLT} `subIds` token is transferred to this contract via {IDLT-safeTransferFrom}
* by `operator` from `sender`, this function is called.
* MUST return its Solidity selector to confirm the token transfers.
* MUST revert if any other value is returned or the interface is not implemented by the recipient.
* The selector can be obtained in Solidity with `IDLTReceiver.onDLTReceived.selector`.
* @param operator is the address which initiated the transfer
* @param from is the address which previously owned the token
* @param mainIds is the main token type ID being transferred
* @param subIds subId is the token subtype ID being transferred
* @param amounts is the amount of tokens being transferred
* @param data is additional data with no specified format
* @return `IDLTReceiver.onDLTReceived.selector`
*/functiononDLTBatchReceived(addressoperator,addressfrom,uint256[]calldatamainIds,uint256[]calldatasubIds,uint256[]calldataamounts,bytescalldatadata)externalreturns(bytes4);}