ERC1155Lib

ERC1155Lib

derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)

TransferSingle

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

TransferBatch

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

ApprovalForAll

event ApprovalForAll(address account, address operator, bool approved)

_balanceOf

function _balanceOf(address account, uint256 id) internal view returns (uint256)

query the balance of given token held by given address

Parameters

Name
Type
Description

account

address

address to query

id

uint256

token to query

Return Values

Name
Type
Description

[0]

uint256

token balance

_mint

function _mint(address account, uint256 id, uint256 amount, bytes data) internal

mint given quantity of tokens for given address

ERC1155Receiver implementation is not checked

Parameters

Name
Type
Description

account

address

beneficiary of minting

id

uint256

token ID

amount

uint256

quantity of tokens to mint

data

bytes

data payload

_safeMint

function _safeMint(address account, uint256 id, uint256 amount, bytes data) internal

mint given quantity of tokens for given address

Parameters

Name
Type
Description

account

address

beneficiary of minting

id

uint256

token ID

amount

uint256

quantity of tokens to mint

data

bytes

data payload

_mintBatch

function _mintBatch(address account, uint256[] ids, uint256[] amounts, bytes data) internal

mint batch of tokens for given address

ERC1155Receiver implementation is not checked

Parameters

Name
Type
Description

account

address

beneficiary of minting

ids

uint256[]

list of token IDs

amounts

uint256[]

list of quantities of tokens to mint

data

bytes

data payload

_safeMintBatch

function _safeMintBatch(address account, uint256[] ids, uint256[] amounts, bytes data) internal

mint batch of tokens for given address

Parameters

Name
Type
Description

account

address

beneficiary of minting

ids

uint256[]

list of token IDs

amounts

uint256[]

list of quantities of tokens to mint

data

bytes

data payload

_burn

function _burn(address account, uint256 id, uint256 amount) internal

burn given quantity of tokens held by given address

Parameters

Name
Type
Description

account

address

holder of tokens to burn

id

uint256

token ID

amount

uint256

quantity of tokens to burn

_burnBatch

function _burnBatch(address account, uint256[] ids, uint256[] amounts) internal

burn given batch of tokens held by given address

Parameters

Name
Type
Description

account

address

holder of tokens to burn

ids

uint256[]

token IDs

amounts

uint256[]

quantities of tokens to burn

_transfer

function _transfer(address operator, address sender, address recipient, uint256 id, uint256 amount, bytes data) internal

transfer tokens between given addresses

ERC1155Receiver implementation is not checked

Parameters

Name
Type
Description

operator

address

executor of transfer

sender

address

sender of tokens

recipient

address

receiver of tokens

id

uint256

token ID

amount

uint256

quantity of tokens to transfer

data

bytes

data payload

_safeTransfer

function _safeTransfer(address operator, address sender, address recipient, uint256 id, uint256 amount, bytes data) internal

transfer tokens between given addresses

Parameters

Name
Type
Description

operator

address

executor of transfer

sender

address

sender of tokens

recipient

address

receiver of tokens

id

uint256

token ID

amount

uint256

quantity of tokens to transfer

data

bytes

data payload

_transferBatch

function _transferBatch(address operator, address sender, address recipient, uint256[] ids, uint256[] amounts, bytes data) internal

transfer batch of tokens between given addresses

ERC1155Receiver implementation is not checked

Parameters

Name
Type
Description

operator

address

executor of transfer

sender

address

sender of tokens

recipient

address

receiver of tokens

ids

uint256[]

token IDs

amounts

uint256[]

quantities of tokens to transfer

data

bytes

data payload

_safeTransferBatch

function _safeTransferBatch(address operator, address sender, address recipient, uint256[] ids, uint256[] amounts, bytes data) internal

transfer batch of tokens between given addresses

Parameters

Name
Type
Description

operator

address

executor of transfer

sender

address

sender of tokens

recipient

address

receiver of tokens

ids

uint256[]

token IDs

amounts

uint256[]

quantities of tokens to transfer

data

bytes

data payload

_beforeTokenTransfer

function _beforeTokenTransfer(address operator, address from, address to, uint256[] ids, uint256[] amounts, bytes data) internal

ERC1155 hook, called before all transfers including mint and burn

function should be overridden and new implementation must call super called for both single and batch transfers

Parameters

Name
Type
Description

operator

address

executor of transfer

from

address

sender of tokens

to

address

receiver of tokens

ids

uint256[]

token IDs

amounts

uint256[]

quantities of tokens to transfer

data

bytes

data payload

_balanceOfBatch

function _balanceOfBatch(address[] accounts, uint256[] ids) internal view returns (uint256[])

query the balances of given tokens held by given addresses

Parameters

Name
Type
Description

accounts

address[]

addresss to query

ids

uint256[]

tokens to query

Return Values

Name
Type
Description

[0]

uint256[]

token balances

totalSupply

function totalSupply(uint256 id) internal view returns (uint256)

query total minted supply of given token

Parameters

Name
Type
Description

id

uint256

token id to query

Return Values

Name
Type
Description

[0]

uint256

token supply

isApprovedForAll

function isApprovedForAll(address account, address operator) internal view returns (bool)

Was this helpful?