func IsErc721(address string, client *ethclient.Client) (isErc721 bool, detail addressdetail.AddressDetail, err error) {
	detail.Address = address

	addr := common.HexToAddress(address)
	instance, err := erc721.NewErc721(addr, client)
	if err != nil {
		return false, detail, err
	}

	isErc721, err = instance.SupportsInterface(nil, erc165.InterfaceIdErc165)
	if err != nil || !isErc721 {
		return isErc721, detail, err
	}

	// It appears to be ERC721
	detail.Type = addressdetail.AddressTypeErc721

	// Try to get a name and symbol
	detail.Name, _ = instance.Name(nil)
	// if err != nil {
	// 	// eg. "abi: cannot marshal in to go slice: offset 33 would go over slice boundary (len=32)"
	// 	// ignore, since we don't check erc721 metadata extension
	// }

	detail.Symbol, _ = instance.Symbol(nil)
	// if err != nil {
	// 	// ignore, since we don't check erc721 metadata extension
	// }

	return true, detail, nil
}
// TODO: Currently returns true for every SC that supports INTERFACEID_ERC165. It should really be INTERFACEID_ERC721,
// but that doesn't detect some SCs, eg. cryptokitties https://etherscan.io/address/0x06012c8cf97BEaD5deAe237070F9587f8E7A266d#readContract
// As a quick fix, just checks ERC165 and count it as ERC721 address. Improve with further/better SC method checks.
Currently returns true for every SC that supports INTERFACEID_ERC165. It should really be INTERFACEID_ERC721,
but that doesn't detect some SCs, eg.
// TODO : Currently returns true for every SC that supports INTERFACEID_ERC165 . It should really be INTERFACEID_ERC721 // but that doesn ' t detect some SCs eg . cryptokitties https : // etherscan . io / address / 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d#readContract // As a quick fix just checks ERC165 and count it as ERC721 address . Improve with further / better SC method checks .
func IsErc721(address string, client *ethclient.Client) (isErc721 bool, detail addressdetail.AddressDetail, err error) {
	detail.Address = address
	addr := common.HexToAddress(address)
	instance, err := erc721.NewErc721(addr, client)
	if err != nil {
		return false, detail, err
	}
	isErc721, err = instance.SupportsInterface(nil, erc165.InterfaceIdErc165)
	if err != nil || !isErc721 {
		return isErc721, detail, err
	}
	detail.Type = addressdetail.AddressTypeErc721
	detail.Name, _ = instance.Name(nil)
	detail.Symbol, _ = instance.Symbol(nil)
	return true, detail, nil
}
func IsErc721 ( address string , client * ethclient . Client ) ( isErc721 bool , detail addressdetail . AddressDetail , err error ) { detail . Address = address addr := common . HexToAddress ( address ) instance , err := erc721 . NewErc721 ( addr , client ) if err != nil { return false , detail , err } isErc721 , err = instance . SupportsInterface ( nil , erc165 . InterfaceIdErc165 ) if err != nil || ! isErc721 { return isErc721 , detail , err } detail . Type = addressdetail . AddressTypeErc721 detail . Name , _ = instance . Name ( nil ) detail . Symbol , _ = instance . Symbol ( nil ) return true , detail , nil }
Currently returns true for every SC that supports INTERFACEID_ERC165.
Currently returns true for every SC that supports INTERFACEID_ERC165 .
// It appears to be ERC721 // Try to get a name and symbol // if err != nil { // 	// eg. "abi: cannot marshal in to go slice: offset 33 would go over slice boundary (len=32)" // 	// ignore, since we don't check erc721 metadata extension // } // if err != nil { // 	// ignore, since we don't check erc721 metadata extension // }