-
Notifications
You must be signed in to change notification settings - Fork 1
/
xdnft.sh
1430 lines (1230 loc) · 65.6 KB
/
xdnft.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
version="version 0.5"
version=" dev 0.5"
# Activate Chia Environment
appdir=`pwd`
cd ~/chia-blockchain
. ./activate
cd $appdir
# define some colors
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
bldgrn='\e[1;32m' # Bold Green
bldpur='\e[1;35m' # Bold Purple
txtrst='\e[0m' # Text Reset
display_banner()
{
echo -e "${bldgrn}"
echo -e " _ __ _ _ _ "
echo -e " | | / _| | (_) | |"
echo -e " __ ____| | _ __ | |_| |_ __ ___ ______ _ _ __ __| |"
echo -e " \ \/ / _' | | '_ \| _| __| \ \ /\ / / |_ / _' | '__/ _' |"
echo -e " > < (_| | | | | | | | |_ \ V V /| |/ / (_| | | | (_| |"
echo -e " /_/\_\__,_| |_| |_|_| \__| \_/\_/ |_/___\__,_|_| \__,_|"
echo -e " ------------------------------------------------------------${txtred}"
echo -e " Interactive script to help with NFT tasks. $version${bldgrn}"
echo -e " ------------------------------------------------------------"
}
mojo2xch()
{
local mojo=$1
local xch=""
# cant do floating division in Bash but we know xch is always mojo/10000000000
# so we can use string manipulation to build the xch value from mojo
mojolength=`expr length $mojo`
if [ $mojolength -eq 12 ]; then
xch="0.$mojo"
elif [ $mojolength -lt 12 ]; then
temp=`printf "%012d" $mojo`
xch="0.$temp"
else
off=$(($mojolength - 12))
off2=$(($off + 1))
temp1=`echo $mojo | cut -c1-$off`
temp2=`echo $mojo | cut -c$off2-$mojolength`
xch="$temp1.$temp2"
fi
echo "$xch"
}
get_nft_json()
{
local id=$1
local json=`curl -s https://api.mintgarden.io/nfts/$id`
echo "$json"
}
get_collection_json()
{
local collection_id=$1
local json=`curl -s https://api.mintgarden.io/collections/$collection_id`
echo "$json"
}
get_collection_floor()
{
collection_json=$(get_collection_json $1)
collection_floor=$(echo "$collection_json" | jq '.floor_price' | cut --fields 2 --delimiter=:)
if [ "$collection_floor" == null ]; then
collection_floor=0
fi
echo "$collection_floor"
}
get_nft_name()
{
local json=$1
local nft_name=`echo "$json" | jq '.data.metadata_json.name' | cut --fields 2 --delimiter=\" `
echo "$nft_name"
}
get_nft_coin_id()
{
local id=$1
local nft_coin_id=`chia wallet nft get_info -ni $id | grep "Current NFT coin ID" | cut -c 28-`
echo "$nft_coin_id"
}
get_nft_cost()
{
local json=$1
local nft_cost=`echo "$nft_json" | jq '.events[].xch_price' | tail -n 1`
if [ "$nft_cost" == null ]; then
nft_cost=0
fi
echo "$nft_cost"
}
nft_details()
{
local id=$1
local val=$2
local nft_json
local nft_collection
local nft_name
local nft_coin_id
nft_json=$(get_nft_json $id)
nft_collection_id=`echo "$nft_json" | jq '.collection.id' | cut --fields 2 --delimiter=\"`
nft_collection_name=`echo "$nft_json" | jq '.collection.name' | cut --fields 2 --delimiter=\"`
nft_name=`echo "$nft_json" | jq '.data.metadata_json.name' | cut --fields 2 --delimiter=\"`
nft_coin_id=$(get_nft_coin_id $id)
#nft_cost=$(get_nft_cost $nft_json)
#nft_floor=$(get_collection_floor $nft_collection_id)
echo -e " Wallet ID: ${txtrst}$val${bldgrn}"
echo -e " NFT Coin ID: ${txtrst}$nft_coin_id${bldgrn}"
echo -e " NFT ID: ${txtrst}$id${bldgrn}"
echo -e " NFT Name: ${txtrst}$nft_name${bldgrn}"
echo -e " NFT Col ID: ${txtrst}$nft_collection_id${bldgrn}"
echo -e " NFT Col Name: ${txtrst}$nft_collection_name${bldgrn}"
#echo -e " NFT Cost: ${txtrst}$nft_cost xch${bldgrn}"
#echo -e " NFT Floor: ${txtrst}$nft_floor xch${bldgrn}"
}
get_wallet_list()
{
local wallet_list=`chia wallet show -w nft | grep "Wallet ID" | cut -c 28- | tr '\n' ' '`
echo "$wallet_list"
}
get_fingerprint()
{
fingerprint=`chia wallet show | grep "fingerprint:" | cut -c 24-`
echo "$fingerprint"
}
get_my_dids()
{
my_dids=`chia wallet show -w decentralized_id | grep "DID ID" | cut -c 28-`
echo "$my_dids"
}
sleep_countdown()
{
secs=$(($1))
while [ $secs -gt 0 ]; do
echo -ne " $secs\033[0K\r"
sleep 1
: $((secs--))
done
}
send_nft()
{
local nft_id=$1
local display=$2
if [ "$nft_id" == "" ]; then
read -p " NFT ID? " nft_id
fi
nft_wallet_id=$(get_wallet_id $nft_id)
coin_id=$(get_nft_coin_id $nft_id)
if [ "$display" == "true" ]; then
echo ""
echo -e " Searching for ${txtrst}$nft_id${bldgrn}..."
echo ""
nft_details $nft_id $nft_wallet_id
fi
# get destination wallet address
echo ""
read -p " Destination address? " destination
# get fee to send in mojos
echo ""
fee_mojos=""
read -p " [Enter] for 1 mojo fee, or specific number of mojos: " fee_mojos
if [ "$fee_mojos" == "" ]; then
fee_mojos="1"
fi
echo ""
# convert fee_mojos to fee_xch
fee_xch=$(mojo2xch $fee_mojos)
# get the current fingerprint
fingerprint=$(get_fingerprint)
# build transfer command and display
cmd="~/chia-blockchain/venv/bin/chia wallet nft transfer -f $fingerprint -i $nft_wallet_id -m $fee_xch -ni $coin_id -ta $destination"
echo " COMMAND"
echo -e " ${txtrst}$cmd${bldgrn}"
# run transfer command
echo ""
read -p " Run command Y/N? " run
if [ "$run" == "Y" ] || [ "$run" == "y" ]; then
~/chia-blockchain/venv/bin/chia wallet nft transfer -f $fingerprint -i $nft_wallet_id -m $fee_xch -ni $coin_id -ta $destination
fi
}
create_offer()
{
local nft_list=$1
offer_name=`echo "$nft_list" | cut --fields 1 --delimiter=\ `
#local nft_wallet_id=$(get_wallet_id $nft_id)
local fingerprint=$(get_fingerprint)
echo ""
read -p " Sale amount? " amount
echo ""
fee_mojos=""
read -p " [Enter] for 1 mojo fee, or specific number of mojos: " fee_mojos
if [ "$fee_mojos" == "" ]; then
fee_mojos="1"
fi
# convert fee_mojos to fee_xch
fee_xch=$(mojo2xch $fee_mojos)
# chia wallet make_offer -f FINGERPRINT -o WALLET_ID:AMOUNT -r WALLET_ID:AMOUNT -p PATH -m FEE
cmd="~/chia-blockchain/venv/bin/chia wallet make_offer -f $fingerprint -m $fee_xch \"$nft_list\" -r 1:$amount -p $appdir/files/$offer_name.offer"
echo " COMMAND"
echo -e " ${txtrst}$cmd${bldgrn}"
echo ""
read -p " Run command Y/N? " run
if [ "$run" == "Y" ] || [ "$run" == "y" ]; then
~/chia-blockchain/venv/bin/chia wallet make_offer -f $fingerprint -m $fee_xch "$nft_list" -r 1:$amount -p $appdir/files/$offer_name.offer
fi
}
upload_offer()
{
local nft_list=$1
offer_name=`echo "$nft_list" | cut --fields 1 --delimiter=\ `
# first make sure the offer file exsits
if [ -f "$appdir/files/$offer_name.offer" ]; then
offer_content=`cat $appdir/files/$offer_name.offer`
response=`curl -X POST -H 'Content-Type: application/json' -d '{"offer":"'$offer_content'"}' https://api.dexie.space/v1/offers`
offer_success=`echo $response | jq '.success'`
offer_id=`echo $response | jq '.id'`
echo ""
echo " Success: $offer_success"
echo " Offer ID: $offer_id"
else
echo "Cannot find $offer_name.offer file in $appdir/files."
fi
}
get_wallet_id()
{
local nft_id=$1
local nft_wallet_id=""
wallet_list=$(get_wallet_list)
# search for wallet id containing nft id
for val in $wallet_list; do
nft_id_list=`chia wallet nft list -i $val | grep "NFT identifier" | cut -c 28-`
for id in $nft_id_list; do
if [ "$id" == "$nft_id" ]; then
nft_wallet_id="$val"
break 2
fi
done
done
echo "$nft_wallet_id"
}
get_did_from_nft_id()
{
local id=$1
nft_json=$(get_nft_json $id)
did_id=`echo "$nft_json" | jq '.owner.encoded_id' | cut --fields 2 --delimiter=\"`
echo "$did_id"
}
menu()
{
echo ""
echo " 1. View NFT details by NFT ID"
echo " 2. Send NFT to Wallet Address"
echo " 3. Get list of my NFTs"
echo " 4. Get list of NFT IDs from Collection"
echo " 5. Get list of Owner Wallets from NFT IDs"
echo " 6. Get list of NFT Names from NFT IDs"
echo " 7. Name generators"
echo " 8. Pick Random NFT, Optional Airdrop"
echo " 9. Bulk Move NFTs to Profile/DID"
echo "10. Get Owner DID from NFT ID"
echo "11. Sale "
echo "12. BURN 🔥🔥🔥"
echo " x. Exit"
echo ""
read -p " Selection: " menu_selection
###########################################################
# Exit menu
###########################################################
if [ "$menu_selection" == "X" ] || [ "$menu_selection" == "x" ] ||[ "$menu_selection" == "" ]; then
echo ""
exit
fi
###########################################################
# View NFT details by NFT ID
###########################################################
if [ "$menu_selection" == "1" ]; then
echo ""
read -p " NFT ID? " nft_id
echo -e " Searching for ${txtrst}$nft_id${bldgrn}..."
echo ""
nft_wallet_id=$(get_wallet_id $nft_id)
nft_details $nft_id $nft_wallet_id
fi
###########################################################
# Send NFT to Wallet Address
###########################################################
if [ "$menu_selection" == "2" ]; then
echo ""
nft_id=""
read -p " NFT ID? " nft_id
echo ""
send_nft $nft_id "true"
fi
###########################################################
# Create a list of my NFTs
###########################################################
if [ "$menu_selection" == "3" ]; then
echo ""
wallet_list=`chia wallet show -w nft | grep "Wallet ID" | cut -c 28- | tr '\n' ' '`
echo -e " NFT Wallet IDs: ${txtrst}$wallet_list${bldgrn}"
echo ""
read -p " Wallet ID, or [Enter] for all, or [x] to cancel? " answer_wallet
total_cost=0
total_floor=0
if [ "$answer_wallet" != "X" ] && [ "$answer_wallet" != "x" ]; then
if [ "$answer_wallet" != "" ]; then
wallet_list="$answer_wallet"
fi
all=0
for val in $wallet_list; do
echo ""
echo " ==== Wallet ID: $val ===="
c=`chia wallet nft list -i $val | grep "NFT identifier" | wc -l`
nft_ids=`chia wallet nft list -i $val | grep "NFT identifier" | cut -c 28-`
for id in $nft_ids; do
nft_json=`curl -s https://api.mintgarden.io/nfts/$id`
nft_collection=`echo "$nft_json" | jq '.collection.name' | cut --fields 2 --delimiter=\"`
nft_collection_id=`echo "$nft_json" | jq '.collection.id' | cut --fields 2 --delimiter=\"`
nft_name=`echo "$nft_json" | jq '.data.metadata_json.name' | cut --fields 2 --delimiter=\"`
#nft_cost=$(get_nft_cost $nft_json)
#nft_floor=$(get_collection_floor $nft_collection_id)
#total_cost=$(($total_cost+$nft_cost))
#total_floor=$(($total_floor+$nft_floor))
#echo -e "${txtrst}$id [$nft_collection] $nft_name -- Cost: $nft_cost -- Floor: $nft_floor${bldgrn}"
echo -e "${txtrst}$id [$nft_collection] $nft_name${bldgrn}"
done
echo -e " Wallet Count Total: ${txtrst}$c${bldgrn}"
all=$(($all+$c))
done
echo ""
echo -e " Total number of NFTs: ${txtrst}$all${bldgrn}"
echo ""
echo -e " Total Cost: ${txtrst}$total_cost${bldgrn}"
echo -e " Total Floor: ${txtrst}$total_floor${bldgrn}"
fi
fi
###########################################################
# Get list of NFT IDs from Collection
###########################################################
if [ "$menu_selection" == "4" ]; then
echo ""
echo -e " You will need the Collection ID. You can find this on ${txtrst}https://mintgarden.io${bldgrn}"
echo -e ""
echo -e " Search for your collection name ie. BattleKats which should result in a page with a URL like such:"
echo -e " ${txtrst}https://mintgarden.io/collections/battlekats-col1kmrzafjx6ej8w79tz5vnjt4w8xuq2p6nmnheelgwwu3rsgsar0fsxc4wud${bldgrn}"
echo -e ""
echo -e " You Collection ID is everything after the hyphen in the URL."
echo -e " For example: ${txtrst}col1kmrzafjx6ej8w79tz5vnjt4w8xuq2p6nmnheelgwwu3rsgsar0fsxc4wud${bldgrn}"
echo -e ""
read -p " Collection ID? " collection_id
if [ "$collection_id" != "X" ] && [ "$collection_id" != "x" ]; then
nfts=`curl -s https://api.mintgarden.io/collections/$collection_id/nfts/ids`
echo -e "${txtrst}"
nft_list=`echo "$nfts" | jq '.[].encoded_id' | cut --fields 2 --delimiter=\"`
for id in $nft_list; do
echo -e "$id"
done
echo -e "${bldgrn}"
fi
fi
###########################################################
# Get list of Owner Wallets from NFT IDs
###########################################################
if [ "$menu_selection" == "5" ]; then
echo ""
echo " 1. Single NFT ID"
echo " 2. File of NFT IDs"
echo ""
read -p " Selection? " submenu_select
if [ "$submenu_select" == "1" ]; then
echo ""
read -p " NFT ID? " nft_ids
else
echo ""
read -p " Filename? " filename
nft_ids=`cat $filename`
fi
echo ""
read -p " Output to Screen or File S/F? " output_type
if [ "$output_type" == "F" ] || [ "$output_type" == "f" ]; then
read -p " Filename to save as? " outfile
if [ -f "$outfile" ]; then
rm $outfile
touch $outfile
fi
fi
n=1
for id in $nft_ids; do
nft_json=`curl -s https://api.mintgarden.io/nfts/$id`
nft_owner_wallet=`echo "$nft_json" | jq '.owner_address.encoded_id' | cut --fields 2 --delimiter=\"`
#outputting to the console screen slows the script down
if [ "$output_type" == "S" ] || [ "$output_type" == "s" ]; then
echo -e "${txtrst}$nft_owner_wallet,$id${bldgrn}"
fi
if [ "$output_type" == "F" ] || [ "$output_type" == "f" ]; then
echo "$nft_owner_wallet,$id" >> $appdir/$outfile
fi
n=$(($n+1))
done
fi
###########################################################
# Get list of NFT Names from NFT IDs"
###########################################################
if [ "$menu_selection" == "6" ]; then
echo ""
echo " 1. Single NFT ID"
echo " 2. File of NFT IDs"
echo ""
read -p " Selection? " submenu_select
if [ "$submenu_select" == "1" ]; then
echo ""
read -p " NFT ID? " nft_ids
else
echo ""
read -p " Filename? " filename
nft_ids=`cat $filename`
fi
echo ""
read -p " Output to Screen or File S/F? " output_type
if [ "$output_type" == "F" ] || [ "$output_type" == "f" ]; then
read -p " Filename to save as? " outfile
if [ -f "$outfile" ]; then
rm $outfile
touch $outfile
fi
fi
n=1
for id in $nft_ids; do
nft_json=`curl -s https://api.mintgarden.io/nfts/$id`
nft_id=`echo "$nft_json" | jq '.encoded_id' | cut --fields 2 --delimiter=\"`
nft_name=`echo "$nft_json" | jq '.data.metadata_json.name' | cut --fields 2 --delimiter=\"`
if [ "$output_type" == "S" ] || [ "$output_type" == "s" ]; then
echo -e "${txtrst}$nft_id,$nft_name${bldgrn}"
fi
if [ "$output_type" == "F" ] || [ "$output_type" == "f" ]; then
echo "$nft_id,$nft_name" >> $appdir/$outfile
fi
done
fi
###########################################################
# Name Generators
###########################################################
if [ "$menu_selection" == "7" ]; then
echo ""
echo " 1. Droid Name Generator - create list of unique names based on a galaxy far, far away."
echo " 2. Norby Name Generator - create list of names in this pattern: AAAA-9999. Can allow duplicates or force to be unique."
echo " 3. Random Name Picker - select 1 or 2 word names from text files. Allow duplicates or force unique names."
echo ""
read -p " Selection? " submenu_select
if [ "$submenu_select" == "1" ]; then
echo " Droid Name Generator"
echo ""
read -p " How many names to create? " num
for (( c=0; c<$num; c++ ))
do
# let make sure each name is unique, so loop until we create a new one
available=0
until [[ "$available" -eq "1" ]]; do
alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
name=""
case $(( RANDOM % 100 )) in
0|99)
# 0-0-0 style, weight: 2%
name="$name$[($RANDOM % 10)]"
name="$name-"
name="$name$[($RANDOM % 10)]"
name="$name-"
name="$name$[($RANDOM % 10)]" ;;
1|30|50|70|98)
# R-3X style, weight: 5%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name-"
name="$name$[($RANDOM % 10)]"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}" ;;
12|22|42|62|82|92)
# EV-9D9 style, weight: 6%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name-"
name="$name$[($RANDOM % 10)]"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name$[($RANDOM % 10)]" ;;
6|26|56|76|86|96)
# C1-10P style, weight: 6%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name$[($RANDOM % 10)]"
name="$name-"
name="$name$[($RANDOM % 10)]"
name="$name$[($RANDOM % 10)]"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}" ;;
7|17|27|67|77|87|97)
# MSE-6 style, weight: 7%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name-"
name="$name$[($RANDOM % 10)]" ;;
31|32|35|36|37|38|39)
# L3-37 style, weight: 7%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name$[($RANDOM % 10)]"
name="$name-"
name="$name$[($RANDOM % 10)]"
name="$name$[($RANDOM % 10)]" ;;
40|41|45|46|47|49|94)
# 2-1B style, weight: 7%
name="$name$[($RANDOM % 10)]"
name="$name-"
name="$name$[($RANDOM % 10)]"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}" ;;
15|52|57|61|89)
# D-O style, weight: 5%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name-"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}" ;;
5|25|55|65|85|90|91|95)
# AP-5 style, weight: 8%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name-"
name="$name$[($RANDOM % 10)]" ;;
9|11|20|54|69|71|72|81)
# IG-11 style, weight: 8%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name-"
name="$name$[($RANDOM % 10)]"
name="$name$[($RANDOM % 10)]" ;;
4|14|24|34|44|64|74|84)
# 4-LOM style, weight: 8%
name="$name$[($RANDOM % 10)]"
name="$name-"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}" ;;
8|18|28|29|48|58|68|78|88)
# BB-8 style, weight: 9%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name-"
name="$name$[($RANDOM % 10)]" ;;
3|10|13|23|33|43|53|63|73|83|93)
# C-3PO style, weight: 10%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name-"
name="$name$[($RANDOM % 10)]"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}" ;;
2|16|19|21|51|59|60|66|75|79|80)
# R2-D2 style, weight: 10%
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name$[($RANDOM % 10)]"
name="$name-"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name$[($RANDOM % 10)]" ;;
esac
if [[ ! " ${used[*]} " =~ " ${name} " ]]; then
available=1
fi
done
used+=("$name")
echo -e "${txtrst}$name${bldgrn}"
done
fi
if [ "$submenu_select" == "2" ]; then
echo " Norby Name Generator"
echo ""
read -p " How many names to create? " num
for (( c=0; c<$num; c++ ))
do
# let make sure each name is unique, so loop until we create a new one
available=0
until [[ "$available" -eq "1" ]]; do
alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
name=""
#first the alphas
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name${alphabet:$((RANDOM % ${#alphabet})):1}"
name="$name-"
#then the digits
name="$name$[($RANDOM % 10)]"
name="$name$[($RANDOM % 10)]"
name="$name$[($RANDOM % 10)]"
name="$name$[($RANDOM % 10)]"
if [[ ! " ${used[*]} " =~ " ${name} " ]]; then
available=1
fi
done
used+=("$name")
echo -e "${txtrst}$name${bldgrn}"
done
fi
if [ "$submenu_select" == "3" ]; then
infile1=""
infile2=""
file1=""
file2=""
unique=0
num=0
echo " Random Name Picker"
echo ""
read -p " How many names to create? " num
echo ""
read -p " How many words 1 or 2? " words
echo ""
read -p " Unique Y/N? " unique
if [ "$unique" == "Y" ] || [ "$unique" == "y" ]; then
unique=1
fi
if [ "$words" == "1" ] || [ "$words" == "2" ]; then
echo " Be sure you don't have blank lines in the file or those will be counted as possibles values."
echo ""
read -p " First word filename? " infile1
if [ "$words" == "2" ]; then
echo ""
read -p " Second word filename? " infile2
fi
# Import name file
# Sort and print the name arrays to verify you don't have repeats
# Get Number of records in files
if [[ -f "$infile1" ]]; then
name1=`cat $infile1`
one=( $( for x in ${name1[@]}; do echo $x; done | sort) )
file1count=`cat $infile1 | wc -l` && file1count=$(($file1count-1))
else
echo " ERROR: Could not find file to use for names."
exit 1
fi
if [[ -f "$infile2" ]]; then
name2=`cat $infile2`
two=( $( for x in ${name2[@]}; do echo $x; done | sort) )
file2count=`cat $infile2 | wc -l` && file2count=$(($file2count-1))
fi
# loop through each file and create metadata file
for (( itm=1; itm<=$num; itm++ ))
do
if [[ "$unique" -eq "1" ]]; then
# MUST BE UNIQUE NAMES
# generate a new name until we have one that isn't already used.
available=0
until [[ "$available" -eq "1" ]]; do
if [[ -f "$infile2" ]]; then
a=`shuf -i 0-$file1count -n1`
b=`shuf -i 0-$file2count -n1`
myname="${one[a]} ${two[b]}"
else
a=`shuf -i 0-$file1count -n1`
myname="${one[a]}"
fi
if [[ ! " ${used_names[*]} " =~ " ${myname} " ]]; then
available=1
fi
done
used_names+=( "$myname" )
echo -e "${txtrst}$myname${bldgrn}"
else
# REPEATS are okay
if [[ -f "$infile2" ]]; then
a=`shuf -i 0-$file1count -n1`
b=`shuf -i 0-$file2count -n1`
myname="${one[a]} ${two[b]}"
else
a=`shuf -i 0-$file1count -n1`
myname="${one[a]}"
fi
echo -e "${txtrst}$myname${bldgrn}"
fi
done
fi
fi
fi
###############################################################
# Randomly Select an NFT from All or by Wallet ID or Collection
###############################################################
if [ "$menu_selection" == "8" ]; then
isokay="r"
echo ""
echo " 1. Randomly select one from all my NFTs"
echo " 2. Randomly select one from a specific Wallet ID"
echo " 3. Randomly select one from a specific Collection"
echo ""
read -p " Selection? " random_type
# One from all my NFTs
if [ "$random_type" == "1" ]; then
# get a list of nft wallet ids
wallet_list=`chia wallet show -w nft | grep "Wallet ID" | cut -c 28- | tr '\n' ' '`
while [ "$isokay" == "r" ]; do
c=1
nft_count=0
full_nft_list=""
for val in $wallet_list; do
nft_id_list=`chia wallet nft list -i $val | grep "NFT identifier" | cut -c 28-`
full_nft_list=$(echo -e "$full_nft_list\n$nft_id_list")
c=$(($c+1))
done
echo "$full_nft_list" > $appdir/files/.full_list
# using sed to remove any blank lines from the file so our nft count will be correct.
sed -i '/^$/d' $appdir/files/.full_list
full_list=`cat $appdir/files/.full_list`
nft_list=( $( for x in ${full_list[@]}; do echo $x; done | sort) )
nft_count=`cat $appdir/files/.full_list | wc -l`
echo ""
echo -e " Total all NFTs: ${txtrst}$nft_count${bldgrn}"
echo ""
nft_count=$(($nft_count-1))
random_index=`shuf -i 0-$nft_count -n1`
nft_id="${nft_list[random_index]}"
nft_wallet_id=$(get_wallet_id $nft_id)
nft_details $nft_id $nft_wallet_id
echo ""
read -p " [y] to continue, [r] to redo, or [c] to cancel? " isokay
done
echo ""
if [ "$isokay" != "c" ]; then
read -p " Airdrop Y/N? " airdrop
if [ "$airdrop" == "Y" ] || [ "$airdrop" == "y" ]; then
send_nft $nft_id "false"
fi
fi
fi
# One from a specific Wallet ID
if [ "$random_type" == "2" ]; then
while [ "$isokay" == "r" ]; do
echo ""
wallet_id_list=""
nft_count=0
# get a list of nft wallet ids
wallet_list=`chia wallet show -w nft | grep "Wallet ID" | cut -c 28- | tr '\n' ' '`
echo -e " Wallet IDs: ${txtrst}$wallet_list${bldgrn}"
echo ""
read -p " Chosen Wallet ID? " wallet_id
wallet_id_list=`chia wallet nft list -i $wallet_id | grep "NFT identifier" | cut -c 28-`
echo "$wallet_id_list" | tr ' ' '\n' > $appdir/files/.wid_$wallet_id
wid_list=`cat $appdir/files/.wid_$wallet_id`
nft_list=( $( for x in ${wid_list[@]}; do echo $x; done | sort) )
nft_count=`cat $appdir/files/.wid_$wallet_id | wc -l`
echo ""
echo -e " Total all NFTs: ${txtrst}$nft_count${bldgrn}"
nft_count=$(($nft_count-1))
random_index=`shuf -i 0-$nft_count -n1`
nft_id="${nft_list[random_index]}"
echo ""
nft_wallet_id=$(get_wallet_id $nft_id)
nft_details $nft_id $nft_wallet_id
echo ""
read -p " [y] to continue, [r] to redo, or [c] to cancel? " isokay
done
echo ""
if [ "$isokay" != "c" ]; then
read -p " Airdrop Y/N? " airdrop
if [ "$airdrop" == "Y" ] || [ "$airdrop" == "y" ]; then
send_nft $nft_id "false"
fi
fi
fi
# One from a specific Collection
if [ "$random_type" == "3" ]; then
while [ "$isokay" == "r" ]; do
echo ""
read -p " Collection ID? " collection_id
official_collection_ids=`curl -s "https://api.mintgarden.io/collections/$collection_id/nfts/ids" | jq '.[].encoded_id' | cut --fields 2 --delimiter=\"`
collection_list=""
full_list=""
nft_count=0
# get a list of nft wallet ids
wallet_list=`chia wallet show -w nft | grep "Wallet ID" | cut -c 28- | tr '\n' ' '`
c=1
for val in $wallet_list; do
nft_id_list=`chia wallet nft list -i $val | grep "NFT identifier" | cut -c 28-`
for id in $nft_id_list; do
for oc_id in $official_collection_ids; do
if [ "$id" == "$oc_id" ]; then
collection_list="$collection_list $id"
fi
done
done
c=$(($c+1))
done
collection_list=`echo $collection_list | tr ' ' '\n'`
echo "$collection_list" | tr ' ' '\n' > $appdir/files/.$collection_id
my_list=`cat $appdir/files/.$collection_id`
nft_list=( $( for x in ${my_list[@]}; do echo $x; done | sort) )
nft_count=`cat $appdir/files/.$collection_id | wc -l`
echo ""
echo -e " Total my NFTs in Collection: ${txtrst}$nft_count${bldgrn}"
nft_count=$(($nft_count-1))
random_index=`shuf -i 0-$nft_count -n1`
nft_id="${nft_list[random_index]}"
echo ""
nft_wallet_id=$(get_wallet_id $nft_id)
nft_details $nft_id $nft_wallet_id
echo ""
read -p " [y] to continue, [r] to redo, [c] to cancel? " isokay
done
echo ""
if [ "$isokay" != "c" ]; then
read -p " Airdrop Y/N? " airdrop
if [ "$airdrop" == "Y" ] || [ "$airdrop" == "y" ]; then
send_nft $nft_id "false"
fi
fi
fi
fi
###########################################################
# Bulk Move NFTs to Profile/DID
###########################################################
if [ "$menu_selection" == "9" ]; then
echo ""
echo -e " 1. Single NFT ID"
echo -e " 2. File of NFT IDs"
echo ""
read -p " Selection? " submenu_select
echo ""
my_dids=$(get_my_dids)
fingerprint=$(get_fingerprint)
# get fee to send in mojos
fee_mojos=""
read -p " [Enter] for 1 mojo fee, or specific number of mojos: " fee_mojos
if [ "$fee_mojos" == "" ]; then
fee_mojos="1"
fi
echo ""
# convert fee_mojos to fee_xch
fee_xch=$(mojo2xch $fee_mojos)
if [ "$submenu_select" == "1" ]; then
read -p " NFT ID? " nft_id
echo -e ""
echo -e " DIDs: "
echo -e "${txtrst}$my_dids${bldgrn}"
echo -e ""
read -p " DID ID? " did_id
nft_wallet_id=$(get_wallet_id $nft_id)
nft_coin_id=$(get_nft_coin_id $nft_id)
echo ""
unfinished_txs="unknown"
while [[ -n $unfinished_txs ]]
do
unfinished_txs=`chia wallet get_transactions -f $fingerprint -l 5 --sort-by-height --no-paginate | grep -E 'Unconfirmed|Pending'`
if [[ -n $unfinished_txs ]]; then
printf "%s\n" "$unfinished_txs"
sleep_countdown 20
continue
else
printf "TXs clear, moving NFT...\n"
break
fi
done
cmd="~/chia-blockchain/venv/bin/chia wallet nft set_did -f $fingerprint -i $nft_wallet_id -di $did_id -ni $nft_coin_id -m $fee_xch"
echo " COMMAND"
echo -e " ${txtrst}$cmd${bldgrn}"
echo ""
read -p " Run command Y/N? " run
if [ "$run" == "Y" ] || [ "$run" == "y" ]; then
~/chia-blockchain/venv/bin/chia wallet nft set_did -f $fingerprint -i $nft_wallet_id -di $did_id -ni $nft_coin_id -m $fee_xch
fi
else
my_dids=$(get_my_dids)
fingerprint=$(get_fingerprint)
json=""
echo -e " 1. All to one DID [Bulk - 25 max per file]"
echo -e " 2. Each line in file will include DID [Will batch move, not bulk]"
echo ""
read -p " Selection? " method
echo ""
if [ "$method" == "1" ]; then