繁体   English   中英

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

[英]How to check if address is allowed to receive ERC721?

我有我想在 Polygon Network 中创建的地址列表:

["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

您使用的地址是有效的,但是在您使用的 erc721 合约版本中(我不确定这种行为在 openzeppelin 合约的版本 4 中是否发生了变化)以便在合约中接收 erc721合约应该已经实现了这个https://docs.openzeppelin.com/contracts/3.x/api/token/erc721#IERC721Receiver ,以防止代币被锁定在合约中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM