HashLips / hashlips_nft_contract

A simple NFT smart contract that works with the rest of the HashLips ecosystem.
MIT License
834 stars 674 forks source link

Out of Gas Error on walletOfOwner function #36

Open CoffeeFam84 opened 2 years ago

CoffeeFam84 commented 2 years ago

I airdropped 1000 NFTs to the holders. But when I tried to call walletOfOwner function to check holding NFTs, it raises Out of Gas Error. It works for holders holding earlier NFTs (tokenIDs are not high) but doesn't for for others. How can this be fixed?

liarco commented 2 years ago

Hi @SmartDev84, can you please send me the contract address? so I can do some tests?

That function should never be used by other on-chain functions (it's ok to call it from a DAPP or from back end services, where gas should not be a problem). The walletOfOwner() function is provided as an easy-to-use shortcut to grab all tokens from a specific owner from outside the chain only.

For example: the Sketchy Ape Comic Club collection is using our new contract and from Etherscan I can go to the "Read Contract" tab and run the walletOfOwner("0x64a060c7b979e1de998bca7ae30bb700fdaf6998") without any problem, here is the output I'm getting:

[ walletOfOwner(address) method Response ]
    uint256[] : 
  112
  113
  114
  142
  143
  144
  176
  177
  178
  209
  210
  211
  252
  253
  254
  297
  298
  299
  363
  364
  365
  404
  405
  406
  775
  776
  777
  885
  886
  887
  1774
  1775
  1776
  2222
  2223
  2224
  2278
  2279
  2280
  2302
  2303
  2304
  2311
  2312
  2313
  2333
  2334
  2335
  2360
  2361
  2362
  2384
  2385
  2386
  2397
  2398
  2399
  2421
  2422
  2423
  2425
  2426
  2427
  2446
  2447
  2448
  2495
  2496
  2497
  2510
  2511
  2512
  2530
  2531
  2532
  2618
  2619
  2620
  2831
  2832
  2833
  3661
  3662
  3663
  3673
  3674
  3675
  3768
  3769
  3770
  3774
  3775
  3776
  3777
  3778
  3779
  3795
  3796
  3797
  4011
  4012
  4013
  4017
  4018
  4019
  4023
  4024
  4025
  4026
  4027
  4028
  4034
  4035
  4036
  4040
  4041
  4042
  4056
  4057
  4058
  4059
  4060
  4061
  4077
  4078
  4079
  4086
  4087
  4088
  4120
  4121
  4122
  4144
  4145
  4146
  4156
  4157
  4158
  4171
  4172
  4173
  4174
  4175
  4176
  4204
  4205
  4206
  4208
  4209
  4210
  4211
  4212
  4213
  4220
  4221
  4222
  4298
  4299
  4300
  4301
  4302
  4303
  4631
  4632
  4633
  4663
  4664
  4665
  4781
  4782
  4783
  6085
  6331
  7102
  7103
  7104
  7277
  7278
  7279
  7349
  7350
  7351
  7352
  7353
  7354
  7355
  7356
  7357
  7363
  7364
  7365
  7372
  7373
  7374
  7375
  7376
  7377
  7515
  7516
  7517
  7569
  7570
  7571
  7572
  7573
  7574
  7575
  7576
  7577
  7578
  7579
  7580
  7588
  7589
  7590
  7591
  7592
  7593
  7594
  7595
  7596
  7597
  7598
  7599
  7600
  7601
  7602
  7604
  7605
  7606
  7607
  7608
  7609
  7610
  7611
  7612
  7617
  7618
  7619
  7620
  7621
  7622
  7623
  7624
  7625
  7627
  7628
  7629
  7644
  7645
  7646
  7647
  7648
  7649
  7653
  7654
  7655
  7659
  7660
  7661
  7662
  7663
  7664
  7665
  7666
  7667
  7668
  7669
  7670
  7671
  7672
  7673
  7674
  7675
  7676
  7677
  7678
  7679
  7680
  7681
  7682
  7683
  7684
  7685
  7689
  7690
  7691
  7692
  7693
  7694
  7698
  7699
  7700
  7701
  7702
  7703
  7704
  7705
  7706
  7707
  7708
  7709
  7710
  7711
  7712
  7713
  7714
  7715
  7716
  7717
  7718
  7722
  7723
  7724
  7728
  7729
  7730
  7731
  7732
  7733
  7734
  7735
  7736
  7741
  7742
  7743
  7744
  7745
  7746
  7750
  7751
  7752
  7753
  7754
  7755
  7758
  7759
  7760
  7761
  7762
  7763
  7764
  7765
  7766
  7767
  7768
  7769
  7770
  7771
  7772
  7773
  7774
  7775
  7779
  7780
  7781
  7785
  7786
  7787
  7794
  7795
  7796
  7797
  7798
  7799
  7800
  7801
  7802
  7803
  7804
  7805
  7806
  7807
  7808
  7812
  7813
  7814
  7815
  7816
  7817
  7818
  7819
  7820
  7821
  7822
  7823
  7824
  7825
  7826
  7827
  7828
  7829
  7836
  7837
  7838
  7839
  7841
  7845
  7846
  7847
  7851
  7852
  7853
  7860
  7861
  7862
  7871
  7872
  7873
  7890
  7891
  7892
  7893
  7894
  7895
  7896
  7897
  7898
  8395
  9594

This address is from a whale owning 420 tokens, the highest one is 9594 so pretty high as a token ID.