0

I am inheriting a contract from the OZ 1155 contract:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol

It contains a function _safeTransferFrom that I have copied to my own contract. However, when compiling the contract, I get the following error:

DeclarationError: Undeclared identifier.
  --> project:/contracts/YieldToken.sol:97:50:
   |
97 |         _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
   |                                                  ^^^^^^^^^^^^^^^^^

,DeclarationError: Undeclared identifier.
  --> project:/contracts/YieldToken.sol:97:73:
   |
97 |         _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
   |                                                                         ^^^^^^^^^^^^^^^^^

,DeclarationError: Undeclared identifier.
  --> project:/contracts/YieldToken.sol:99:31:
   |
99 |         uint256 fromBalance = _balances[id][from];
   |                               ^^^^^^^^^

,DeclarationError: Undeclared identifier.
   --> project:/contracts/YieldToken.sol:102:13:
    |
102 |             _balances[id][from] = fromBalance - amount;
    |             ^^^^^^^^^

,DeclarationError: Undeclared identifier.
   --> project:/contracts/YieldToken.sol:104:9:
    |
104 |         _balances[id][to] += amount;
    |         ^^^^^^^^^

,DeclarationError: Undeclared identifier.
   --> project:/contracts/YieldToken.sol:108:9:
    |
108 |         _doSafeTransferAcceptanceCheck(opertor, from, to, id, amount, data);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Compilation failed. See above.

I get a bunch of undeclared identifiers. However, the 1155 contract that I'm inheriting from does contain those functions and those variables. Why is it showing undeclared identifier and how to fix this?

0

functions _asSingletonArray and _doSafeTransferAcceptanceCheck are private so you can't call them by inheriting!

Also _balances is a private mapping, same goes for it too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.