将字符串用于 uint256 不适用于 ERC721EnumerableUpgradeable

Using Strings for uint256 not working with ERC721EnumerableUpgradeable

就像标题说我无法使用字符串进行编译一样,我一直找不到标识符。 这是我的 .sol 合同的开始

import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";

contract NFT is Initializable, StringsUpgradeable, ERC721EnumerableUpgradeable, OwnableUpgradeable {
using Strings for uint256; 

请帮忙!

谢谢!

导入的 StringsUpgradeable.sol 文件包含名为 StringsUpgradeable 的库,而不是 Strings

此外,由于它是一个库,因此无法继承,因此您需要将其从 NFT parents.

的列表中删除
pragma solidity ^0.8;

import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";

// removed `StringsUpgradable` from the parents list
contract NFT is Initializable, ERC721EnumerableUpgradeable, OwnableUpgradeable {

    // replaced `Strings` to `StringsUpgradable`
    using StringsUpgradeable for uint256; 
}