> For the complete documentation index, see [llms.txt](https://docs.kubchain.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kubchain.com/quickstart/launching-a-token-on-kub/kap-token-interfaces/kap-1155.md).

# KAP-1155

The following standard outlines a smart contract interface that can represent any number of fungible and non-fungible token types on KUB. This multi-token standard supports an `adminTransfer` function designed to create transactions on behalf of NFT holders if they have been a victim of a fraudulent transaction. It is proposed by deriving the ERC-1155 standard of Ethereum with additional functions related to `adminTransfer`.

{% hint style="info" %}
The `id` argument contained in each function's argument set indicates a specific token or token type in a transaction.
{% endhint %}

## Token Interface

### IAdminProjectRouter

#### isSuperAdmin

Check whether `_addr` is the Super Admin role in `_project`.

```solidity
function isSuperAdmin(address _addr, string calldata _project) external view returns (bool)
```

#### isAdmin

Check whether `_addr` is the Admin role in `_project`.

```solidity
function isAdmin(address _addr, string calldata _project) external view returns (bool)
```

### IKYCBitkubChain

#### kycsLevel

Returns the KYC Level of `_addr`.

```solidity
function kycsLevel(address _addr) external view returns (uint256)
```

#### setKycCompleted

Set the KYC Level `_level` of `_addr`.

```solidity
function setKycCompleted(address _addr, uint256 _level) external
```

### IKAP165

#### supportsInterface

Check whether the contract implements `interfaceID`, and `interfaceID` is not `0xffffffff`.

* MUST return the constant value `true` if `0x01ffc9a7` is passed through the `interfaceID` argument. This signifies KAP-165 support.
* MUST return the constant value `true` if `0x4e2312e0` is passed through the `interfaceID` argument. This signifies KAP-1155 `IKAP1155Receiver` support.

```solidity
function supportsInterface(bytes4 interfaceId) external view returns (bool)
```

### IKAP1155

#### balanceOf

Return the balance of `account` by `id` token ID.

```solidity
function balanceOf(address account, uint256 id) external view returns (uint256)
```

#### balanceOfBatch

Returns multiple balances of `accounts` by `id` token ID.

```solidity
function balanceOfBatch(address[] calldata accounts, uint256[] calldata id) external view returns (uint256[] memory)
```

#### setApprovalForAll

Enable or disable approval for a third party `operator` to manage all of `msg.sender`'s assets.

`approve` true if the `operator` is approved, false to revoke approval.

Emits the `ApprovalForAll` event. The contract MUST allow multiple operators per owner.

```solidity
function setApprovalForAll(address operator, bool approved) external
```

#### isApprovedForAll

Check whether `operator` is an approved operator for `owner`.

```solidity
function isApprovedForAll(address account, address operator) external view returns (bool)
```

{% hint style="info" %}
NOTE: Query if an address `operator` is an authorized operator for another address `owner`.
{% endhint %}

#### adminTransfer

Transfers `amount` amount of `id` token ID from the `sender` address to the `recipient` address specified, and MUST fire the `TransferSingle` event to reflect the balance change.

```solidity
function adminTransfer(address sender, address recipient, uint256 id, uint256 amount) external
```

{% hint style="info" %}
NOTE: This function can only be called by the Committee address required in the constructor. This function is designed to create transactions automatically on behalf of token holders if they have been a victim of a fraudulent transaction. This method works similarly to the `safeTransferFrom` method.
{% endhint %}

#### internalTransfer

Transfers `amount` amount of `id` token ID from the `sender` address to the `recipient` address internally and MUST fire the `TransferSingle` event to reflect the balance change.

The function SHOULD `throw` if the message caller's account balance for token `id` is lower than the `amount` sent. Tokens can be transferred between internal addresses that have completed KYC for both the address `sender` and the address `recipient` using the `internalTransfer` function.

```solidity
function internalTransfer(address sender, address recipient, uint256 id, uint256 amount) external returns (bool)
```

{% hint style="info" %}
NOTE: This function can only be called by the Super Admin and the Transfer Router.
{% endhint %}

#### externalTransfer

Transfers `amount` amount of `id` token ID from the `sender` address to the `recipient` address externally and MUST fire the `TransferSingle` event to reflect the balance change.

The function SHOULD `throw` if the message caller’s account balance for token `id` is lower than the `amount` sent. Tokens can be transferred between internal addresses that have completed KYC for both the address `sender` and the address `recipient` using the `internalTransfer` function.

```solidity
function externalTransfer(address sender, address recipient, uint256 id, uint256 amount) external returns (bool)
```

{% hint style="info" %}
NOTE: This function can only be called by the Super Admin and the Transfer Router.
{% endhint %}

#### safeTransferFrom

Transfers `amount` amount of an `id` token ID from the `from` address to the `to` address specified (with safety call). The caller must be approved to manage the token being transferred out of the `from` account.

* MUST revert if `to` is the zero address.
* MUST revert if balance of holder for token `id` is lower than the `amount` sent.
* MUST revert on any other error.
* MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard).

After the above conditions are met, this function MUST check if `to` is a smart contract (code size > 0). If so, it MUST call `onKAP1155Received` on `to` and act appropriately.

```solidity
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external
```

#### safeBatchTransferFrom

Transfers `amounts` amount of `ids` token ID from the `from` address to the `to` address specified (with safety call). The caller must be approved to manage the tokens being transferred out of the `from` account.

* MUST revert if `to` is the zero address.
* MUST revert if the length of `ids` is not the same as the length of `amounts`.
* MUST revert if any of the balance(s) of the holder(s) for token(s) in `ids` is lower than the respective amount(s) in `amounts` sent to the recipient.
* MUST revert on any other error.
* MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard).

Balance changes and events MUST follow the ordering of the arrays ( `ids[0]`/ `amounts[0]` before `ids[1]`/ `amounts[1]`, etc).

After the above conditions for the transfer(s) in the batch are met, this function MUST check if `to` is a smart contract (code size > 0). If so, it MUST call the relevant `IKAP1155Receiver` hook(s) on `to` and act appropriately (see "Safe Transfer Rules" section of the standard).

```solidity
function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external
```

### Events

#### TransferSingle

Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning.

The `operator` MUST be the address of an account/contract that is approved to make the transfer (SHOULD be `msg.sender`).

The `from` MUST be the address of the holder whose balance is decreased.

The `to` MUST be the address of the recipient whose balance is increased.

The `id` MUST be the token type being transferred.

The `value` MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by.

When minting/creating tokens, the `from` argument MUST be set to `0x0` (zero address).

When burning/destroying tokens, the `to` argument MUST be set to `0x0` (zero address).

```solidity
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)
```

#### TransferBatch

Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning.

The `operator` MUST be the address of an account/contract that is approved to make the transfer (SHOULD be `msg.sender`).

The `from` MUST be the address of the holder whose balance is decreased.

The `to` MUST be the address of the recipient whose balance is increased.

The `ids` MUST be the list of tokens being transferred.

The `values` MUST be the list of numbers of tokens (matching the list and order of tokens specified in `ids`) the holder balance is decreased by and match what the recipient's balance is increased by.

When minting/creating tokens, the `from` argument MUST be set to `0x0` (zero address).

When burning/destroying tokens, the `to` argument MUST be set to `0x0` (zero address).

```solidity
event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values)
```

#### ApprovalForAll

This event MUST be emitted when approval for an `operator` address to manage all tokens for an `account` address is enabled or disabled (absence of an event assumes disabled).

```solidity
event ApprovalForAll(address indexed account, address indexed operator, bool approved)
```

#### URI

This event MUST be emitted when the URI is updated for a token ID. URIs are defined in RFC 3986. The URI MUST point to a JSON file that conforms to the "KAP1155 Metadata URI JSON Schema".

```solidity
event URI(string value, uint256 indexed id)
```

### IKAP1155Receiver

#### onKAP1155Received

Handle the receipt of a single KAP1155 token type. A KAP1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeTransferFrom` after the balance has been updated.

This function MUST return `bytes4(keccak256("onKAP1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61) if it accepts the transfer.

This function MUST revert if it rejects the transfer.

Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller.

```solidity
function onKAP1155Received(address operator, address from, uint256 id, uint256 value, bytes calldata data) external returns (bytes4)
```

#### onKAP1155BatchReceived

Handle the receipt of multiple KAP1155 token types. A KAP1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeBatchTransferFrom` after the balances have been updated.

This function MUST return `bytes4(keccak256("onKAP1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81) if it accepts the transfer(s).

This function MUST revert if it rejects the transfer(s).

Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller.

```solidity
function onKAP1155BatchReceived(address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data) external returns (bytes4)
```

### IKAP1155Metadata

#### name

A descriptive name for a collection of tokens in this contract.

```solidity
function name() external view returns (string memory)
```

#### symbol

An abbreviated name for tokens in this contract.

```solidity
function symbol() external view returns (string memory)
```

#### uri

A distinct Uniform Resource Identifier (URI) for a given asset.

`throw` if `tokenID` is not a valid token. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the “KAP1155 Metadata JSON Schema”.

```solidity
function uri(uint256 tokenId) external view returns (string memory)
```

#### kapURI

A distinct Uniform Resource Identifier (URI) for a given asset that is kept in the IPFS service.

`throw` if `tokenID` is not a valid token. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the “KAP1155 Metadata JSON Schema”.

```solidity
function kapURI(uint256 tokenId) external view returns (string memory)
```

### IKAP1155Enumerable

#### totalSupply

Returns a count of valid tokens tracked by this contract, where each one of them has an assigned and queryable owner not equal to the zero address.

```solidity
function totalSupply() external view returns (uint256)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kubchain.com/quickstart/launching-a-token-on-kub/kap-token-interfaces/kap-1155.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
