当前位置: 首页 > 知识库问答 >
问题:

如何检查地址是否允许接收ERC721?

邹曦之
2023-03-14

我有这个地址列表,我想铸币在多边形网络:

["0x8d520d016246f31fe7a676648f1fd5e55ec5562d","0x5a52b317ed280c90d903d9605c2f41acbbc4b066","0x1bd7dabaae1b0d3f82cb47e182502b019f796b1c","0x35c81e79e1c49718db71b95179600e8c2472571d","0x4675e69560d9750a3682944a9dfa1b4fe3cda279","0x101a036ba89748a2c05431c7b088342758d38ab5","0x2bcc25c0cc7c8bb097b58b076b68574483af2985","0x55c052df9d0238a77dbf40931c26409c60955ff3","0x9024f7a9159e76b90029e0964f74d69d2b34c1a2","0x6441303870f67bbc3bb9665c6e951ed501d16233","0x2433ec4e8b0878ac4d7c7bf56e1fdf2b8977b06d","0x45d4bd22ca029d805cf971a2a53f884666e916df","0xbe6e3669464e7db1e1528212f0bff5039461cb82","0xd8dfba40a13df7f9270154bf13b293b732fea1f0","0x4772c5be232ba11daf20c1985c02338b0f8f871a","0xa691ea9bb77464c0a7def21a175a7d281dd44a0e","0x32619ea96a1260e7215bd71b711882769d5b3dc3","0xa28872727a46b0827527fb04540f52933db577ed","0x841ce48f9446c8e281d3f1444cb859b4a6d0738c","0xe7f80963f9ec6c449a120b68cae5571f87237e41","0xf7fbf80fa09975042ef620e8d6ef54af8bf2cc46","0xeb21e84c68d8e9fb4371e3b3686ecdf5e81de689","0x661d3005506aea3def4422606b1a31be9cef1d80","0xef9702ea316e52b4e771ef3ba81930320c4b88e6","0x4e3144dcd9b91a6acd7ea238afb74fb789fcd03a","0xf7b30915db932ec94e04a7f0208a63cc8eb87aa9","0x0c3d5fb65c2bdf9aaffc420303c523b55c3dca6c","0x16f33b3d0272f897d9bc55282fa151215215602c","0x4081c28448038d4eca175e89312c174fdf9c6a0d","0x22475406fa38e0747d88766dc38417ecc73e4adf","0xc22f5b5ccf5c718582460e6450391f738fdaf005","0xab25a1276b9fa7e2cb64b6e858cdc35d71213e48","0xc830cf22bbb93f5eaf380496054f74d497499cec","0x9619d3fa1f29c1de8fcfacedc07321637c1f0c3b","0x961c90b02232c2678eaf864627eaa20438d70ef2","0xfbb6aa0ba4a9ee610b9f0fea384e9d597c676a5f","0x4327342ccc2b7dd74751a5193ceb36ba5ce33567","0xcd5e2f67325d01bf4d9535a939428e2d8dab261d","0x81513aedaf902b0024168616de85361e5ff9cc28","0x166ed9f7a56053c7c4e77cb0c91a9e46bbc5e8b0","0x57043ee3d107de959e55e6932892874623fc961d","0x2831c1a4bbf6d7f5af915f0e09767a0463e12cfa","0x6a4d2b58a53b2dc960be1a888f279426a97b847f","0xd5f6f246507ffa6191c9d1851474dfe1782c5d25","0xc40bdf4aa875b6104381901e064f16bcb775789f","0xebb2db2d6c51a68bdee10470fe994fe3a4e53d23","0xd39a43b25f38e1ff7ec48420bff88743386688d6","0xfe03ea2901ffc6db88e7dc2410b0e98dff8f50ab","0x726dd921b64ebd09318e827d13f28047aa4a18d2","0xd46b4d81aa6764d00e61ee217a4f5cecd9aa189b"]

由于以下原因,所有地址均有效:

/**
 * Checks if the given string is an address
 *
 * @method isAddress
 * @param {String} address the given HEX adress
 * @return {Boolean}
 */
var isAddress = function (address) {
  if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
    // check if it has the basic requirements of an address
    return false;
  } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
    // If it's all small caps or all all caps, return true
    return true;
  } else {
    // Otherwise check each case
    return isChecksumAddress(address);
  }
};

/**
 * Checks if the given string is a checksummed address
 *
 * @method isChecksumAddress
 * @param {String} address the given HEX adress
 * @return {Boolean}
 */
var isChecksumAddress = function (address) {
  // Check each case
  address = address.replace('0x','');
  var addressHash = sha3.keccak256(address.toLowerCase());
  for (var i = 0; i < 40; i++ ) {
    // the nth letter should be uppercase if the nth digit of casemap is 1
    if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
      return false;
    }
  }
  return true;
};

但我仍然得到以下错误:

PATCH /smart/airdrop/polygon Error: execution reverted: ERC721: transfer to non ERC721Receiver implementer
0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000324552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465720000000000000000000000000000

共有1个答案

司空叶五
2023-03-14

您正在使用的地址是有效的,但在您正在使用的erc721合同版本中(我不确定openzeppelin合同版本4中是否改变了此行为),为了在合同中接收erc721,合同应实现此功能https://docs.openzeppelin.com/contracts/3.x/api/token/erc721#IERC721Receiver,以防止代币被锁定在合同中

 类似资料:
  • 我知道如何检查给定的树是否是二叉树。但问题是,如果树包含重复的值,该怎么办。 如何检查可能包含重复值的树是否是二叉查找树重复值必须位于树/子树的右侧。

  • 问题内容: 我正在使用 com.sun.mail.smtp.SMTPTransport 通过Java发送电子邮件。 我可以成功发送电子邮件,但是如果我将邮件发送到无效的电子邮件地址,则 SMTPTransport 不会出现任何错误。 有没有办法检查给定的邮件地址是否存在? 我的意思不是要检查 客户端 的邮件地址,我需要检查 服务器端的地址 。 我在许多论坛上都发现了许多类似的问题,但是我没有任何适

  • 问题内容: 我想知道与使用if语句先检查null相比,使用try / exception处理null的成本。 提供更多信息。因为在此应用程序中,有> 50%的机会获得空值。如果未输入任何数据,则通常为null。因此,尝试使用null进行计算是很平常的事。 话虽这么说,如果我先使用if语句在计算之前先检查null并且不首先尝试计算是否会提高性能,或者仅抛出异常并对其进行处理会更便宜? 感谢您的任何建

  • 检查给定的IBAN地址是否有效。注意,IBAN对象也有此方法。 调用: web3.eth.Iban.isValid(address) 参数: address:String,要检查的IBAN地址 返回值: Boolean:有效的地址则返回true,否则返回false 示例代码: web3.eth.Iban.isValid("XE81ETHXREGGAVOFYORK"); > true web3.

  • 我在我的Web服务器(Debian/Nginx/Gunicorn)上运行Redis进行会话存储,我有理由相信我的Redis服务器遭到了黑客攻击。这绝对是可能的,因为如果我在另一台机器上针对web服务器运行命令“redis cli-h(HOST IP)”,我就可以进入控制台并运行命令。我有两个问题。首先,如果我在我的iptables文件中添加一个新的部分,如下所示,我会正确地阻止除Web服务器本身之

  • 问题内容: 这看起来很基础,是否允许您将链接放在链接内? 我试图使整个灰色条都可单击以到达某个地方,但是如果用户单击滚轮或移动箭头,则它们是其他链接。查看我当前的代码: 这是一个好习惯吗?我做错了吗?你会怎么做?谢谢您的帮助! 问题答案: 直接来自W3C for HTML4: 12.2.2嵌套链接是非法的由A元素定义的链接和锚点不得嵌套;A元素不得包含任何其他A元素。 由于DTD将LINK元素定义