forked from thirdweb-dev/js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnippets.json
1762 lines (1762 loc) · 116 KB
/
snippets.json
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
{
"ThirdwebSDK": {
"name": "ThirdwebSDK",
"summary": "The main entry point for the thirdweb SDK\n\n\n",
"examples": {},
"methods": [
{
"name": "fromPrivateKey",
"summary": "Get an instance of the thirdweb SDK based on a private key.\n\n",
"remarks": "\n\nThis should only be used for backend services or scripts, with the private key stored in a secure way. **NEVER** expose your private key to the public in any way.\n\n",
"examples": {
"javascript": "const sdk = ThirdwebSDK.fromPrivateKey(\"SecretPrivateKey\", \"mainnet\");",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst sdk = ThirdwebSDK.fromPrivateKey(\"SecretPrivateKey\", \"mainnet\");",
"unity": "Unity does not support instantiating the SDK from a private key. Instantiate the SDK in read-only mode and then connect the user's Wallet."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.fromprivatekey",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.fromprivatekey"
}
},
{
"name": "fromSigner",
"summary": "Get an instance of the thirdweb SDK based on an existing ethers signer\n\n",
"remarks": null,
"examples": {
"javascript": "// get a signer from somewhere (createRandom is being used purely for example purposes)\nconst signer = Wallet.createRandom();\n\n// get an instance of the SDK with the signer already setup\nconst sdk = ThirdwebSDK.fromSigner(signer, \"mainnet\");",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\n// get a signer from somewhere (createRandom is being used purely for example purposes)\nconst signer = Wallet.createRandom();\n\n// get an instance of the SDK with the signer already setup\nconst sdk = ThirdwebSDK.fromSigner(signer, \"mainnet\");",
"unity": "Unity does not support instantiating the SDK from a signer. Instantiate the SDK in read-only mode and then connect the user's Wallet."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.fromsigner",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.fromsigner"
}
},
{
"name": "fromWallet",
"summary": "Get an instance of the thirdweb SDK based on an AbstractWallet\n\n",
"remarks": null,
"examples": {
"javascript": "import { ThirdwebSDK } from \"@thirdweb-dev/sdk\"\n\nconst wallet = new AbstractWalletImplementation();\nconst sdk = await ThirdwebSDK.fromWallet(wallet, \"mainnet\");",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nimport { ThirdwebSDK } from \"@thirdweb-dev/sdk\"\n\nconst wallet = new AbstractWalletImplementation();\nconst sdk = await ThirdwebSDK.fromWallet(wallet, \"mainnet\");",
"unity": "Unity does not support instantiating the SDK from a Wallet. Instantiate the SDK in read-only mode and then connect the user's Wallet."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.fromwallet",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.fromwallet"
}
},
{
"name": "getBalance",
"summary": "Get the native balance of a given address (wallet or contract)\n\n",
"remarks": null,
"examples": {
"javascript": "const balance = await sdk.getBalance(\"0x...\");\nconsole.log(balance.displayValue);",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst balance = await sdk.getBalance(\"0x...\");\nconsole.log(balance.displayValue);",
"unity": "CurrencyValue balance = await sdk.Wallet.GetBalance();"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.getbalance",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.getbalance"
}
},
{
"name": "getContract",
"summary": "Get an instance of a Custom ThirdwebContract\n\n",
"remarks": null,
"examples": {
"javascript": "const contract = await sdk.getContract(\"{{contract_address}}\");",
"python": "",
"go": "",
"react": "const { contract, isLoading, error } = useContract(contractAddress);",
"unity": "// Ensure your sdk is initialized to the same network as the contract\nContract contract = sdk.GetContract(\"<your-smart-contract-address>\");\n \n// For marketplaces and packs:\nMarketplace marketplace = contract.marketplace;\nPack pack = contract.pack;"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.getcontract",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/react/react.usecontract"
}
},
{
"name": "getContract",
"summary": "Get an instance of a Custom ThirdwebContract\n\n",
"remarks": null,
"examples": {
"javascript": "const contract = await sdk.getContract(\"{{contract_address}}\");",
"python": "",
"go": "",
"react": "const { contract, isLoading, error } = useContract(contractAddress);",
"unity": "// Ensure your sdk is initialized to the same network as the contract\nContract contract = sdk.GetContract(\"<your-smart-contract-address>\");\n \n// For marketplaces and packs:\nMarketplace marketplace = contract.marketplace;\nPack pack = contract.pack;"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.getcontract",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/react/react.usecontract"
}
},
{
"name": "getContract",
"summary": "Get an instance of a Custom ThirdwebContract\n\n",
"remarks": null,
"examples": {
"javascript": "const contract = await sdk.getContract(\"{{contract_address}}\");",
"python": "",
"go": "",
"react": "const { contract, isLoading, error } = useContract(contractAddress);",
"unity": "// Ensure your sdk is initialized to the same network as the contract\nContract contract = sdk.GetContract(\"<your-smart-contract-address>\");\n \n// For marketplaces and packs:\nMarketplace marketplace = contract.marketplace;\nPack pack = contract.pack;"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.getcontract",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/react/react.usecontract"
}
},
{
"name": "getContractFromAbi",
"summary": "Get an instance of a Custom contract from a json ABI\n\n",
"remarks": null,
"examples": {
"javascript": "// Import your ABI from a JSON file\nimport myABI from \"./path/to/myABI.json\";\n\nconst contract = sdk.getContractFromAbi(\n \"{{contract_address}}\",\n // Pass in the \"abi\" field from the JSON file\n myABI.abi\n);",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\n// Import your ABI from a JSON file\nimport myABI from \"./path/to/myABI.json\";\n\nconst contract = sdk.getContractFromAbi(\n \"{{contract_address}}\",\n // Pass in the \"abi\" field from the JSON file\n myABI.abi\n);",
"unity": "Contract contract = sdk.GetContract(\"<your-smart-contract-address>\", \"<your-contract-abi>\");"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.getcontractfromabi",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.getcontractfromabi"
}
},
{
"name": "getContractList",
"summary": "Return all the contracts deployed by the specified address\n\n",
"remarks": null,
"examples": {
"javascript": "const contracts = sdk.getContractList(\"{{wallet_address}}\");",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contracts = sdk.getContractList(\"{{wallet_address}}\");"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.getcontractlist",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.thirdwebsdk.getcontractlist"
}
}
],
"properties": [],
"reference": {
"typescript": "https://portal.thirdweb.com/typescript/sdk.ThirdwebSDK"
}
},
"NFTCollection": {
"name": "NFTCollection",
"summary": "",
"examples": {
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract, isLoading, error } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"nft-collection\")\n\n // Now you can use the nftCollection contract in the rest of the component\n}",
"python": "from thirdweb import ThirdwebSDK\n\n# You can customize this to a supported network or your own RPC URL\nnetwork = \"mumbai\"\n\n# Now we can create a new instance of the SDK\nsdk = ThirdwebSDK(network)\n\n# If you want to send transactions, you can instantiate the SDK with a private key instead:\n# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)\n\ncontract = sdk.get_nft_collection(\"{{contract_address}}\")",
"go": "\nimport (\n\t\"github.com/thirdweb-dev/go-sdk/v2/thirdweb\"\n)\n\nprivateKey := \"...\"\nsecretKey := \"...\"\n\nsdk, err := thirdweb.NewThirdwebSDK(\"mumbai\", &thirdweb.SDKOptions{\n\tPrivateKey: privateKey,\n\tSecretKey: secretKey\n})\n\ncontract, err := sdk.GetNFTCollection(\"{{contract_address}}\")\n"
},
"methods": [],
"properties": [],
"reference": {
"python": "https://docs.thirdweb.com/python/nft-collection",
"go": "https://docs.thirdweb.com/go/nft_collection"
}
},
"Edition": {
"name": "Edition",
"summary": "",
"examples": {
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"edition\")\n\n // Now you can use the edition contract in the rest of the component\n}",
"python": "from thirdweb import ThirdwebSDK\n\n# You can customize this to a supported network or your own RPC URL\nnetwork = \"mumbai\"\n\n# Now we can create a new instance of the SDK\nsdk = ThirdwebSDK(network)\n\n# If you want to send transactions, you can instantiate the SDK with a private key instead:\n# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)\n\ncontract = sdk.get_edition(\"{{contract_address}}\")",
"go": "\nimport (\n\t\"github.com/thirdweb-dev/go-sdk/v2/thirdweb\"\n)\n\nprivateKey := \"...\"\nsecretKey := \"...\"\n\nsdk, err := thirdweb.NewThirdwebSDK(\"mumbai\", &thirdweb.SDKOptions{\n\tPrivateKey: privateKey,\n\tSecretKey: secretKey\n})\n\ncontract, err := sdk.GetEditionDrop(\"{{contract_address}}\")\n"
},
"methods": [],
"properties": [],
"reference": {
"python": "https://docs.thirdweb.com/python/edition",
"go": "https://docs.thirdweb.com/go/edition_drop"
}
},
"TokenDrop": {
"name": "TokenDrop",
"summary": "",
"examples": {
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"token-drop\")\n\n // Now you can use the token drop contract in the rest of the component\n}"
},
"methods": [],
"properties": [],
"reference": {}
},
"Token": {
"name": "Token",
"summary": "",
"examples": {
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"token\")\n\n // Now you can use the token contract in the rest of the component\n}",
"python": "from thirdweb import ThirdwebSDK\n\n# You can customize this to a supported network or your own RPC URL\nnetwork = \"mumbai\"\n\n# Now we can create a new instance of the SDK\nsdk = ThirdwebSDK(network)\n\n# If you want to send transactions, you can instantiate the SDK with a private key instead:\n# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)\n\ncontract = sdk.get_token(\"{{contract_address}}\")",
"go": "\nimport (\n\t\"github.com/thirdweb-dev/go-sdk/v2/thirdweb\"\n)\n\nprivateKey := \"...\"\nsecretKey := \"...\"\n\nsdk, err := thirdweb.NewThirdwebSDK(\"mumbai\", &thirdweb.SDKOptions{\n\tPrivateKey: privateKey,\n\tSecretKey: secretKey\n})\n\ncontract, err := sdk.GetToken(\"{{contract_address}}\")\n"
},
"methods": [],
"properties": [],
"reference": {
"python": "https://docs.thirdweb.com/python/token",
"go": "https://docs.thirdweb.com/go/token"
}
},
"NFTDrop": {
"name": "NFTDrop",
"summary": "",
"examples": {
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"nft-drop\")\n\n // Now you can use the nft drop contract in the rest of the component\n}",
"python": "from thirdweb import ThirdwebSDK\n\n# You can customize this to a supported network or your own RPC URL\nnetwork = \"mumbai\"\n\n# Now we can create a new instance of the SDK\nsdk = ThirdwebSDK(network)\n\n# If you want to send transactions, you can instantiate the SDK with a private key instead:\n# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)\n\ncontract = sdk.get_nft_drop(\"{{contract_address}}\")",
"go": "\nimport (\n\t\"github.com/thirdweb-dev/go-sdk/v2/thirdweb\"\n)\n\nprivateKey := \"...\"\nsecretKey := \"...\"\n\nsdk, err := thirdweb.NewThirdwebSDK(\"mumbai\", &thirdweb.SDKOptions{\n\tPrivateKey: privateKey,\n\tSecretKey: secretKey\n})\n\ncontract, err := sdk.GetNFTDrop(\"{{contract_address}}\")\n"
},
"methods": [],
"properties": [],
"reference": {
"python": "https://docs.thirdweb.com/python/nft-drop",
"go": "https://docs.thirdweb.com/go/nft_drop"
}
},
"EditionDrop": {
"name": "EditionDrop",
"summary": "",
"examples": {
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"edition-drop\")\n\n // Now you can use the edition drop contract in the rest of the component\n}",
"python": "from thirdweb import ThirdwebSDK\n\n# You can customize this to a supported network or your own RPC URL\nnetwork = \"mumbai\"\n\n# Now we can create a new instance of the SDK\nsdk = ThirdwebSDK(network)\n\n# If you want to send transactions, you can instantiate the SDK with a private key instead:\n# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)\n\ncontract = sdk.get_edition_drop(\"{{contract_address}}\")",
"go": "\nimport (\n\t\"github.com/thirdweb-dev/go-sdk/v2/thirdweb\"\n)\n\nprivateKey := \"...\"\nsecretKey := \"...\"\n\nsdk, err := thirdweb.NewThirdwebSDK(\"mumbai\", &thirdweb.SDKOptions{\n\tPrivateKey: privateKey,\n\tSecretKey: secretKey\n})\n\ncontract, err := sdk.GetEditionDrop(\"{{contract_address}}\")\n"
},
"methods": [],
"properties": [],
"reference": {
"python": "https://docs.thirdweb.com/python/edition-drop",
"go": "https://docs.thirdweb.com/go/edition_drop"
}
},
"Marketplace": {
"name": "Marketplace",
"summary": "",
"examples": {
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"marketplace\")\n\n // Now you can use the marketplace contract in the rest of the component\n}",
"python": "from thirdweb import ThirdwebSDK\n\n# You can customize this to a supported network or your own RPC URL\nnetwork = \"mumbai\"\n\n# Now we can create a new instance of the SDK\nsdk = ThirdwebSDK(network)\n\n# If you want to send transactions, you can instantiate the SDK with a private key instead:\n# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)\n\ncontract = sdk.get_marketplace(\"{{contract_address}}\")",
"go": "\nimport (\n\t\"github.com/thirdweb-dev/go-sdk/v2/thirdweb\"\n)\n\nprivateKey := \"...\"\nsecretKey := \"...\"\n\nsdk, err := thirdweb.NewThirdwebSDK(\"mumbai\", &thirdweb.SDKOptions{\n\tPrivateKey: privateKey,\n\tSecretKey: secretKey\n})\n\ncontract, err := sdk.GetMarketplace(\"{{contract_address}}\")\n"
},
"methods": [],
"properties": [],
"reference": {
"python": "https://docs.thirdweb.com/python/marketplace",
"go": "https://docs.thirdweb.com/go/marketplace"
}
},
"MarketplaceDirect": {
"name": "MarketplaceDirect",
"summary": "",
"examples": {},
"methods": [],
"properties": [],
"reference": {}
},
"MarketplaceAuction": {
"name": "MarketplaceAuction",
"summary": "",
"examples": {},
"methods": [],
"properties": [],
"reference": {}
},
"Split": {
"name": "Split",
"summary": "Create custom royalty splits to distribute funds.\n\n",
"examples": {
"javascript": "import { ThirdwebSDK } from \"@thirdweb-dev/sdk\";\n\nconst sdk = new ThirdwebSDK(\"{{chainName}}\");\nconst contract = await sdk.getContract(\"{{contract_address}}\", \"split\");",
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"split\")\n\n // Now you can use the split contract in the rest of the component\n}"
},
"methods": [
{
"name": "balanceOf",
"summary": "Get Funds owed to a particular wallet\n\n",
"remarks": "\n\nGet the amount of funds in the native currency held by the contract that is owed to a specific recipient.\n\n",
"examples": {
"javascript": "// The address to check the funds of\nconst address = \"{{wallet_address}}\";\nconst funds = await contract.balanceOf(address);\nconsole.log(funds);",
"python": "",
"go": "",
"react": "// The address to check the funds of\nconst address = \"{{wallet_address}}\";\nconst funds = await contract.balanceOf(address);\nconsole.log(funds);",
"unity": "// Split is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.split.balanceof",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.split.balanceof"
}
},
{
"name": "balanceOfToken",
"summary": "Get non-native Token Funds owed to a particular wallet\n\n",
"remarks": "\n\nGet the amount of funds in the non-native tokens held by the contract that is owed to a specific recipient.\n\n",
"examples": {
"javascript": "// The address to check the funds of\nconst address = \"{{wallet_address}}\";\n// The address of the currency to check the contracts funds of\nconst tokenAddress = \"0x...\"\nconst funds = await contract.balanceOfToken(address, tokenAddress);\nconsole.log(funds);",
"python": "",
"go": "",
"react": "// The address to check the funds of\nconst address = \"{{wallet_address}}\";\n// The address of the currency to check the contracts funds of\nconst tokenAddress = \"0x...\"\nconst funds = await contract.balanceOfToken(address, tokenAddress);\nconsole.log(funds);",
"unity": "// Split is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.split.balanceoftoken",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.split.balanceoftoken"
}
},
{
"name": "getAllRecipients",
"summary": "Get Recipients of this splits contract\n\n",
"remarks": "\n\nGet the data about the shares of every split recipient on the contract\n\n",
"examples": {
"javascript": "const recipients = await contract.getAllRecipients();\nconsole.log(recipients);",
"python": "",
"go": "",
"react": "const recipients = await contract.getAllRecipients();\nconsole.log(recipients);",
"unity": "// Split is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.split.getallrecipients",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.split.getallrecipients"
}
}
],
"properties": [
{
"name": "distribute",
"summary": "Distribute Funds\n\n",
"remarks": "\n\nDistribute funds held by the contract in the native currency to all recipients.\n\n",
"examples": {
"javascript": "await contract.distribute();",
"python": "",
"go": "",
"react": "await contract.distribute();",
"unity": "// Split is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.promise",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.promise"
}
},
{
"name": "distributeToken",
"summary": "Distribute Funds\n\n",
"remarks": "\n\nDistribute funds held by the contract in the native currency to all recipients.\n\n",
"examples": {
"javascript": "// The address of the currency to distribute funds\nconst tokenAddress = \"0x...\"\nawait contract.distributeToken(tokenAddress);",
"python": "",
"go": "",
"react": "// The address of the currency to distribute funds\nconst tokenAddress = \"0x...\"\nawait contract.distributeToken(tokenAddress);",
"unity": "// Split is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.promise",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.promise"
}
},
{
"name": "withdraw",
"summary": "Withdraw Funds\n\n",
"remarks": "\n\nTriggers a transfer to account of the amount of native currency they are owed.\n\n",
"examples": {
"javascript": "// the wallet address that wants to withdraw their funds\nconst walletAddress = \"{{wallet_address}}\"\nawait contract.withdraw(walletAddress);",
"python": "",
"go": "",
"react": "// the wallet address that wants to withdraw their funds\nconst walletAddress = \"{{wallet_address}}\"\nawait contract.withdraw(walletAddress);",
"unity": "// Split is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.promise",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.promise"
}
}
],
"reference": {
"typescript": "https://portal.thirdweb.com/typescript/sdk.Split"
}
},
"Pack": {
"name": "Pack",
"summary": "Create lootboxes of NFTs with rarity based open mechanics.\n\n",
"examples": {
"javascript": "import { ThirdwebSDK } from \"@thirdweb-dev/sdk\";\n\nconst sdk = new ThirdwebSDK(\"{{chainName}}\");\nconst contract = await sdk.getContract(\"{{contract_address}}\", \"pack\");",
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = usePack(\"<YOUR-CONTRACT-ADDRESS>\", \"pack\")\n\n // Now you can use the pack contract in the rest of the component\n}"
},
"methods": [
{
"name": "get",
"summary": "Get a single Pack\n\n",
"remarks": "\n\nGet all the data associated with every pack in this contract.\n\nBy default, returns the first 100 packs, use queryParams to fetch more.\n\n",
"examples": {
"javascript": "const pack = await contract.get(0);\nconsole.log(packs;",
"python": "",
"go": "",
"react": "import { useContract, useNFT } from \"@thirdweb-dev/react\";\n\n// The token ID of the NFT you want to fetch\nconst tokenId = 0;\n\nfunction App() {\n const { contract } = useContract(\"{{contract_address}}\");\n const { data: nft, isLoading, error } = useNFT(contract, tokenId);\n\n if (isLoading) return <div>Fetching NFT…</div>;\n if (error) return <div>Error fetching NFT</div>;\n if (!nft) return <div>NFT not found</div>;\n return <div>NFT: {nft.metadata.name}</div>;\n}",
"unity": "var tokenId = \"0\";\nvar pack = await contract.Get(tokenId);"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.pack.get",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/react/react.usenft"
}
},
{
"name": "getAll",
"summary": "Get All Packs\n\n",
"remarks": "\n\nGet all the data associated with every pack in this contract.\n\nBy default, returns the first 100 packs, use queryParams to fetch more.\n\n",
"examples": {
"javascript": "const packs = await contract.getAll();\nconsole.log(packs;",
"python": "",
"go": "",
"react": "import { useNFTs, useContract } from \"@thirdweb-dev/react\";\n\nfunction App() {\n const { contract } = useContract(contractAddress);\n const { data, isLoading, error } = useNFTs(contract);\n}",
"unity": "var packs = await contract.GetAll();"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.pack.getall",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/react/react.usenfts"
}
},
{
"name": "getOwned",
"summary": "Get Owned Packs\n\n",
"remarks": "\n\nGet all the data associated with the packs owned by a specific wallet.\n\n",
"examples": {
"javascript": "// Address of the wallet to get the packs of\nconst address = \"{{wallet_address}}\";\nconst packss = await contract.getOwned(address);",
"python": "",
"go": "",
"react": "import { useOwnedNFTs, useContract, useAddress } from \"@thirdweb-dev/react\";\n\nfunction App() {\n const address = useAddress();\n const { contract } = useContract(contractAddress);\n const { data, isLoading, error } = useOwnedNFTs(contract, address);\n}",
"unity": "// Address of the Wallet to get the packs of\nvar address = \"{{wallet_address}}\";\nvar packs = await contract.GetOwned(address);"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.pack.getowned",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/react/react.useownednfts"
}
},
{
"name": "getPackContents",
"summary": "Get Pack Contents\n\n",
"remarks": "\n\nGet the rewards contained inside a pack.\n\n",
"examples": {
"javascript": "const packId = 0;\nconst contents = await contract.getPackContents(packId);\nconsole.log(contents.erc20Rewards);\nconsole.log(contents.erc721Rewards);\nconsole.log(contents.erc1155Rewards);",
"python": "",
"go": "",
"react": "const packId = 0;\nconst contents = await contract.getPackContents(packId);\nconsole.log(contents.erc20Rewards);\nconsole.log(contents.erc721Rewards);\nconsole.log(contents.erc1155Rewards);",
"unity": "var packId = \"0\";\nvar contents = await contract.GetPackContents(packId);\nDebug.Log(contents.erc20Rewards);\nDebug.Log(contents.erc721Rewards);\nDebug.Log(contents.erc1155Rewards);"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.pack.getpackcontents",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.pack.getpackcontents"
}
}
],
"properties": [
{
"name": "addPackContents",
"summary": "Add Pack Contents\n\n",
"remarks": "\n\nAdd contents to an existing pack. See {@link Pack.addPackContents}\n\n",
"examples": {
"javascript": "const packContents = {\n // ERC20 rewards to be included in the pack\n erc20Rewards: [\n {\n contractAddress: \"0x...\",\n quantityPerReward: 5,\n quantity: 100,\n totalRewards: 20,\n }\n ],\n // ERC721 rewards to be included in the pack\n erc721Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n }\n ],\n // ERC1155 rewards to be included in the pack\n erc1155Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n quantityPerReward: 1,\n totalRewards: 100,\n }\n ],\n}\n\nconst tx = await contract.addPackContents(packId, packContents);",
"python": "",
"go": "",
"react": "const packContents = {\n // ERC20 rewards to be included in the pack\n erc20Rewards: [\n {\n contractAddress: \"0x...\",\n quantityPerReward: 5,\n quantity: 100,\n totalRewards: 20,\n }\n ],\n // ERC721 rewards to be included in the pack\n erc721Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n }\n ],\n // ERC1155 rewards to be included in the pack\n erc1155Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n quantityPerReward: 1,\n totalRewards: 100,\n }\n ],\n}\n\nconst tx = await contract.addPackContents(packId, packContents);",
"unity": "// Pack token ID\r\nstring packId = \"0\";\r\n\r\nawait contract\r\n .AddPackContents(packId,\r\n new PackRewards()\r\n {\r\n erc1155Rewards =\r\n new List<ERC1155Reward> {\r\n new ERC1155Reward()\r\n {\r\n contractAddress = \"0x...\",\r\n tokenId = \"0\",\r\n quantityPerReward = \"1\"\r\n }\r\n },\r\n erc721Rewards =\r\n new List<ERC721Reward> {\r\n new ERC721Reward()\r\n { contractAddress = \"0x...\", tokenId = \"0\" }\r\n },\r\n erc20Rewards =\r\n new List<ERC20Reward> {\r\n new ERC20Reward()\r\n { contractAddress = \"0x...\", quantityPerReward = \"1\" }\r\n }\r\n });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.bignumberish",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.bignumberish"
}
},
{
"name": "create",
"summary": "Create Pack\n\n",
"remarks": "\n\nCreate a new pack with the given metadata and rewards and mint it to the connected wallet. See {@link Pack.createTo}\n\n",
"examples": {
"javascript": "const pack = {\n // The metadata for the pack NFT itself\n packMetadata: {\n name: \"My Pack\",\n description: \"This is a new pack\",\n image: \"ipfs://...\",\n },\n // ERC20 rewards to be included in the pack\n erc20Rewards: [\n {\n contractAddress: \"0x...\",\n quantityPerReward: 5,\n quantity: 100,\n totalRewards: 20,\n }\n ],\n // ERC721 rewards to be included in the pack\n erc721Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n }\n ],\n // ERC1155 rewards to be included in the pack\n erc1155Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n quantityPerReward: 1,\n totalRewards: 100,\n }\n ],\n openStartTime: new Date(), // the date that packs can start to be opened, defaults to now\n rewardsPerPack: 1, // the number of rewards in each pack, defaults to 1\n}\n\nconst tx = await contract.create(pack);",
"python": "",
"go": "",
"react": "const pack = {\n // The metadata for the pack NFT itself\n packMetadata: {\n name: \"My Pack\",\n description: \"This is a new pack\",\n image: \"ipfs://...\",\n },\n // ERC20 rewards to be included in the pack\n erc20Rewards: [\n {\n contractAddress: \"0x...\",\n quantityPerReward: 5,\n quantity: 100,\n totalRewards: 20,\n }\n ],\n // ERC721 rewards to be included in the pack\n erc721Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n }\n ],\n // ERC1155 rewards to be included in the pack\n erc1155Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n quantityPerReward: 1,\n totalRewards: 100,\n }\n ],\n openStartTime: new Date(), // the date that packs can start to be opened, defaults to now\n rewardsPerPack: 1, // the number of rewards in each pack, defaults to 1\n}\n\nconst tx = await contract.create(pack);",
"unity": "await contract\r\n .Create(new NewPackInput()\r\n {\r\n packMetadata =\r\n new NFTMetadata()\r\n {\r\n name = \"My Pack\",\r\n description = \"My Pack Description\",\r\n image = \"https://myimage.com\",\r\n external_url = \"https://myimage.com\"\r\n },\r\n erc1155Rewards =\r\n new List<ERC1155Contents> {\r\n new ERC1155Contents()\r\n {\r\n contractAddress = \"0x...\",\r\n tokenId = \"0\",\r\n quantityPerReward = \"1\"\r\n }\r\n },\r\n erc721Rewards =\r\n new List<ERC721Contents> {\r\n new ERC721Contents()\r\n {\r\n contractAddress = \"0x...\",\r\n tokenId = \"0\"\r\n }\r\n },\r\n erc20Rewards =\r\n new List<ERC20Contents> {\r\n new ERC20Contents()\r\n {\r\n contractAddress = \"0x...\",\r\n quantityPerReward = \"1\",\r\n totalRewards = \"1\"\r\n }\r\n }\r\n });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.objectinputtype",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.objectinputtype"
}
},
{
"name": "createTo",
"summary": "Create Pack To Wallet\n\n",
"remarks": "\n\nCreate a new pack with the given metadata and rewards and mint it to the specified address.\n\n",
"examples": {
"javascript": "const pack = {\n // The metadata for the pack NFT itself\n packMetadata: {\n name: \"My Pack\",\n description: \"This is a new pack\",\n image: \"ipfs://...\",\n },\n // ERC20 rewards to be included in the pack\n erc20Rewards: [\n {\n contractAddress: \"0x...\",\n quantityPerReward: 5,\n quantity: 100,\n totalRewards: 20,\n }\n ],\n // ERC721 rewards to be included in the pack\n erc721Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n }\n ],\n // ERC1155 rewards to be included in the pack\n erc1155Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n quantityPerReward: 1,\n totalRewards: 100,\n }\n ],\n openStartTime: new Date(), // the date that packs can start to be opened, defaults to now\n rewardsPerPack: 1, // the number of rewards in each pack, defaults to 1\n}\n\nconst tx = await contract.createTo(\"0x...\", pack);",
"python": "",
"go": "",
"react": "const pack = {\n // The metadata for the pack NFT itself\n packMetadata: {\n name: \"My Pack\",\n description: \"This is a new pack\",\n image: \"ipfs://...\",\n },\n // ERC20 rewards to be included in the pack\n erc20Rewards: [\n {\n contractAddress: \"0x...\",\n quantityPerReward: 5,\n quantity: 100,\n totalRewards: 20,\n }\n ],\n // ERC721 rewards to be included in the pack\n erc721Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n }\n ],\n // ERC1155 rewards to be included in the pack\n erc1155Rewards: [\n {\n contractAddress: \"0x...\",\n tokenId: 0,\n quantityPerReward: 1,\n totalRewards: 100,\n }\n ],\n openStartTime: new Date(), // the date that packs can start to be opened, defaults to now\n rewardsPerPack: 1, // the number of rewards in each pack, defaults to 1\n}\n\nconst tx = await contract.createTo(\"0x...\", pack);",
"unity": "// The address to check the funds of\r\nvar address = \"{{wallet_address}}\";\r\nawait contract\r\n .CreateTo(address,\r\n new NewPackInput()\r\n {\r\n packMetadata =\r\n new NFTMetadata()\r\n {\r\n name = \"My Pack\",\r\n description = \"My Pack Description\",\r\n image = \"https://myimage.com\",\r\n external_url = \"https://myimage.com\"\r\n },\r\n erc1155Rewards =\r\n new List<ERC1155Contents> {\r\n new ERC1155Contents()\r\n {\r\n contractAddress = \"0x...\",\r\n tokenId = \"0\",\r\n quantityPerReward = \"1\"\r\n }\r\n },\r\n erc721Rewards =\r\n new List<ERC721Contents> {\r\n new ERC721Contents()\r\n {\r\n contractAddress = \"0x...\",\r\n tokenId = \"0\"\r\n }\r\n },\r\n erc20Rewards =\r\n new List<ERC20Contents> {\r\n new ERC20Contents()\r\n {\r\n contractAddress = \"0x...\",\r\n quantityPerReward = \"1\",\r\n totalRewards = \"1\"\r\n }\r\n }\r\n });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.objectinputtype",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.objectinputtype"
}
},
{
"name": "open",
"summary": "Open Pack\n\n",
"remarks": "\n\n- Open a pack to reveal the contained rewards. This will burn the specified pack and the contained assets will be transferred to the opening users wallet.\n\n",
"examples": {
"javascript": "const tokenId = 0\nconst amount = 1\nconst tx = await contract.open(tokenId, amount);",
"python": "",
"go": "",
"react": "const tokenId = 0\nconst amount = 1\nconst tx = await contract.open(tokenId, amount);",
"unity": "var tokenId = \"0\";\nvar amount = \"1\";\nvar tx = await contract.Open(tokenId, amount);"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.bignumberish",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.bignumberish"
}
},
{
"name": "royalties",
"summary": "Configure royalties\n\n",
"remarks": "\n\nSet your own royalties for the entire contract or per pack\n\n",
"examples": {
"javascript": "// royalties on the whole contract\ncontract.royalties.setDefaultRoyaltyInfo({\n seller_fee_basis_points: 100, // 1%\n fee_recipient: \"0x...\"\n});\n// override royalty for a particular pack\ncontract.royalties.setTokenRoyaltyInfo(packId, {\n seller_fee_basis_points: 500, // 5%\n fee_recipient: \"0x...\"\n});",
"python": "",
"go": "",
"react": "// royalties on the whole contract\ncontract.royalties.setDefaultRoyaltyInfo({\n seller_fee_basis_points: 100, // 1%\n fee_recipient: \"0x...\"\n});\n// override royalty for a particular pack\ncontract.royalties.setTokenRoyaltyInfo(packId, {\n seller_fee_basis_points: 500, // 5%\n fee_recipient: \"0x...\"\n});"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.contractroyalty",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.contractroyalty"
}
}
],
"reference": {
"typescript": "https://portal.thirdweb.com/typescript/sdk.Pack"
}
},
"Vote": {
"name": "Vote",
"summary": "Create a decentralized organization for token holders to vote on proposals.\n\n",
"examples": {
"javascript": "import { ThirdwebSDK } from \"@thirdweb-dev/sdk\";\n\nconst sdk = new ThirdwebSDK(\"{{chainName}}\");\nconst contract = await sdk.getContract(\"{{contract_address}}\", \"vote\");",
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"vote\")\n\n // Now you can use the vote contract in the rest of the component\n}"
},
"methods": [
{
"name": "canExecute",
"summary": "Can Execute\n\n",
"remarks": "\n\nCheck if a proposal can be executed (if the proposal has succeeded).\n\n",
"examples": {
"javascript": "// The proposal ID of the proposal you want to check\nconst proposalId = \"0\";\nconst canExecute = await contract.canExecute(proposalId);\nconsole.log(canExecute);",
"python": "",
"go": "",
"react": "// The proposal ID of the proposal you want to check\nconst proposalId = \"0\";\nconst canExecute = await contract.canExecute(proposalId);\nconsole.log(canExecute);",
"unity": "// Vote is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.vote.canexecute",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.vote.canexecute"
}
},
{
"name": "getAll",
"summary": "Get All Proposals\n\n",
"remarks": "\n\nGet all the proposals in this contract.\n\n",
"examples": {
"javascript": "const proposals = await contract.getAll();\nconsole.log(proposals);",
"python": "",
"go": "",
"react": "const proposals = await contract.getAll();\nconsole.log(proposals);",
"unity": "// Vote is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.vote.getall",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.vote.getall"
}
},
{
"name": "hasVoted",
"summary": "Check If Wallet Voted\n\n",
"remarks": "\n\nCheck if a specified wallet has voted a specific proposal\n\n",
"examples": {
"javascript": "// The proposal ID of the proposal you want to check\nconst proposalId = \"0\";\n// The address of the wallet you want to check to see if they voted\nconst address = \"{{wallet_address}}\";\n\nawait contract.hasVoted(proposalId, address);",
"python": "",
"go": "",
"react": "// The proposal ID of the proposal you want to check\nconst proposalId = \"0\";\n// The address of the wallet you want to check to see if they voted\nconst address = \"{{wallet_address}}\";\n\nawait contract.hasVoted(proposalId, address);",
"unity": "// Vote is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.vote.hasvoted",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.vote.hasvoted"
}
}
],
"properties": [
{
"name": "execute",
"summary": "Execute Proposal\n\n",
"remarks": "\n\nExecute the related transactions for a proposal if the proposal succeeded.\n\n",
"examples": {
"javascript": "// The proposal ID of the proposal you want to execute\nconst proposalId = \"0\"\nawait contract.execute(proposalId);",
"python": "",
"go": "",
"react": "// The proposal ID of the proposal you want to execute\nconst proposalId = \"0\"\nawait contract.execute(proposalId);",
"unity": "// Vote is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.promise",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.promise"
}
},
{
"name": "propose",
"summary": "Create Proposal\n\n",
"remarks": "\n\nCreate a new proposal for token holders to vote on.\n\n",
"examples": {
"javascript": "// The description of the proposal you want to pass\nconst description = \"This is a great proposal - vote for it!\"\n// You can (optionally) pass in contract calls that will get executed when the proposal is executed.\nconst executions = [\n {\n // The contract you want to make a call to\n toAddress: \"0x...\",\n // The amount of the native currency to send in this transaction\n nativeTokenValue: 0,\n // Transaction data that will be executed when the proposal is executed\n // This is an example transfer transaction with a token contract (which you would need to set up in code)\n transactionData: tokenContract.encoder.encode(\n \"transfer\", [\n fromAddress,\n amount,\n ]\n ),\n }\n]\n\nconst proposal = await contract.propose(description, executions);",
"python": "",
"go": "",
"react": "// The description of the proposal you want to pass\nconst description = \"This is a great proposal - vote for it!\"\n// You can (optionally) pass in contract calls that will get executed when the proposal is executed.\nconst executions = [\n {\n // The contract you want to make a call to\n toAddress: \"0x...\",\n // The amount of the native currency to send in this transaction\n nativeTokenValue: 0,\n // Transaction data that will be executed when the proposal is executed\n // This is an example transfer transaction with a token contract (which you would need to set up in code)\n transactionData: tokenContract.encoder.encode(\n \"transfer\", [\n fromAddress,\n amount,\n ]\n ),\n }\n]\n\nconst proposal = await contract.propose(description, executions);",
"unity": "// Vote is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.proposalexecutable",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.proposalexecutable"
}
},
{
"name": "vote",
"summary": "Vote\n\n",
"remarks": "\n\nVote on an active proposal\n\n",
"examples": {
"javascript": "// The proposal ID of the proposal you want to vote on\nconst proposalId = \"0\";\n// The vote type you want to cast, can be VoteType.Against, VoteType.For, or VoteType.Abstain\nconst voteType = VoteType.For;\n// The (optional) reason for the vote\nconst reason = \"I like this proposal!\";\n\nawait contract.vote(proposalId, voteType, reason);",
"python": "",
"go": "",
"react": "// The proposal ID of the proposal you want to vote on\nconst proposalId = \"0\";\n// The vote type you want to cast, can be VoteType.Against, VoteType.For, or VoteType.Abstain\nconst voteType = VoteType.For;\n// The (optional) reason for the vote\nconst reason = \"I like this proposal!\";\n\nawait contract.vote(proposalId, voteType, reason);",
"unity": "// Vote is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.votetype",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.votetype"
}
}
],
"reference": {
"typescript": "https://portal.thirdweb.com/typescript/sdk.Vote"
}
},
"Multiwrap": {
"name": "Multiwrap",
"summary": "Multiwrap lets you wrap any number of ERC20, ERC721 and ERC1155 tokens you own into a single wrapped token bundle.\n\n",
"examples": {
"javascript": "import { ThirdwebSDK } from \"@thirdweb-dev/sdk\";\n\nconst sdk = new ThirdwebSDK(\"{{chainName}}\");\nconst contract = await sdk.getContract(\"{{contract_address}}\", \"multiwrap\");",
"react": "import { useContract } from '@thirdweb-dev/react'\n\nexport default function Component() {\n const { contract } = useContract(\"<YOUR-CONTRACT-ADDRESS>\", \"multiwrap\")\n\n // Now you can use the multiwrap contract in the rest of the component\n}",
"python": "from thirdweb import ThirdwebSDK\n\n# You can customize this to a supported network or your own RPC URL\nnetwork = \"mumbai\"\n\n# Now we can create a new instance of the SDK\nsdk = ThirdwebSDK(network)\n\n# If you want to send transactions, you can instantiate the SDK with a private key instead:\n# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)\n\ncontract = sdk.get_multiwrap(\"{{contract_address}}\")",
"go": "\nimport (\n\t\"github.com/thirdweb-dev/go-sdk/v2/thirdweb\"\n)\n\nprivateKey := \"...\"\nsecretKey := \"...\"\n\nsdk, err := thirdweb.NewThirdwebSDK(\"mumbai\", &thirdweb.SDKOptions{\n\tPrivateKey: privateKey,\n\tSecretKey: secretKey\n})\n\ncontract, err := sdk.GetMultiwrap(\"{{contract_address}}\")\n"
},
"methods": [
{
"name": "getWrappedContents",
"summary": "Get the contents of a wrapped token bundle\n\n",
"remarks": null,
"examples": {
"javascript": "const contents = await contract.getWrappedContents(wrappedTokenId);\nconsole.log(contents.erc20Tokens);\nconsole.log(contents.erc721Tokens);\nconsole.log(contents.erc1155Tokens);",
"python": "token_id = 0\ncontents = contract.get_wrapped_contents(token_id)\nprint(contents.erc20_tokens)\nprint(contents.erc721_tokens)\nprint(contents.erc1155_tokens)",
"go": "tokenId := 0\ncontents, err := contract.GetWrappedContents(tokenId)\nerc20Tokens := contents.Erc20Tokens\nerc721Tokens := contents.Erc721Tokens\nerc1155Tokens := contents.Erc1155Tokens\n",
"react": "const contents = await contract.getWrappedContents(wrappedTokenId);\nconsole.log(contents.erc20Tokens);\nconsole.log(contents.erc721Tokens);\nconsole.log(contents.erc1155Tokens);",
"unity": "// Multiwrap is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.multiwrap.getwrappedcontents",
"python": "https://docs.thirdweb.com/python/multiwrap#get_wrapped_contents",
"go": "https://docs.thirdweb.com/go/multiwrap#func-multiwrap-getwrappedcontents",
"react": "https://portal.thirdweb.com/typescript/sdk.multiwrap.getwrappedcontents"
}
}
],
"properties": [
{
"name": "royalties",
"summary": "Configure royalties\n\n",
"remarks": "\n\nSet your own royalties for the entire contract or per token\n\n",
"examples": {
"javascript": "// royalties on the whole contract\ncontract.royalties.setDefaultRoyaltyInfo({\n seller_fee_basis_points: 100, // 1%\n fee_recipient: \"0x...\"\n});\n// override royalty for a particular token\ncontract.royalties.setTokenRoyaltyInfo(tokenId, {\n seller_fee_basis_points: 500, // 5%\n fee_recipient: \"0x...\"\n});",
"python": "",
"go": "",
"react": "// royalties on the whole contract\ncontract.royalties.setDefaultRoyaltyInfo({\n seller_fee_basis_points: 100, // 1%\n fee_recipient: \"0x...\"\n});\n// override royalty for a particular token\ncontract.royalties.setTokenRoyaltyInfo(tokenId, {\n seller_fee_basis_points: 500, // 5%\n fee_recipient: \"0x...\"\n});"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.contractroyalty",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.contractroyalty"
}
},
{
"name": "unwrap",
"summary": "Unwrap a wrapped token bundle, and retrieve its contents\n\n",
"remarks": null,
"examples": {
"javascript": "await contract.unwrap(wrappedTokenId);",
"python": "",
"go": "",
"react": "await contract.unwrap(wrappedTokenId);",
"unity": "// Multiwrap is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.bignumberish",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.bignumberish"
}
},
{
"name": "wrap",
"summary": "Wrap any number of ERC20/ERC721/ERC1155 tokens into a single wrapped token\n\n",
"remarks": null,
"examples": {
"javascript": "const tx = await contract.wrap({\n erc20Tokens: [{\n contractAddress: \"0x...\",\n quantity: \"0.8\"\n }],\n erc721Tokens: [{\n contractAddress: \"0x...\",\n tokenId: \"0\"\n }],\n erc1155Tokens: [{\n contractAddress: \"0x...\",\n tokenId: \"1\",\n quantity: \"2\"\n }]\n}, {\n name: \"Wrapped bundle\",\n description: \"This is a wrapped bundle of tokens and NFTs\",\n image: \"ipfs://...\",\n});\nconst receipt = tx.receipt(); // the transaction receipt\nconst wrappedTokenId = tx.id; // the id of the wrapped token bundle",
"python": "",
"go": "",
"react": "const tx = await contract.wrap({\n erc20Tokens: [{\n contractAddress: \"0x...\",\n quantity: \"0.8\"\n }],\n erc721Tokens: [{\n contractAddress: \"0x...\",\n tokenId: \"0\"\n }],\n erc1155Tokens: [{\n contractAddress: \"0x...\",\n tokenId: \"1\",\n quantity: \"2\"\n }]\n}, {\n name: \"Wrapped bundle\",\n description: \"This is a wrapped bundle of tokens and NFTs\",\n image: \"ipfs://...\",\n});\nconst receipt = tx.receipt(); // the transaction receipt\nconst wrappedTokenId = tx.id; // the id of the wrapped token bundle",
"unity": "// Multiwrap is not yet supported in Unity. You can still use the contract.Read and contract.Write functions to call functions directly."
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.tokenstowrap",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.tokenstowrap"
}
}
],
"reference": {
"typescript": "https://portal.thirdweb.com/typescript/sdk.Multiwrap",
"python": "https://docs.thirdweb.com/python/multiwrap",
"go": "https://docs.thirdweb.com/go/multiwrap"
}
},
"ContractDeployer": {
"name": "ContractDeployer",
"summary": "Handles deploying new contracts\n\n@deploy\n\n\n",
"examples": {},
"methods": [],
"properties": [
{
"name": "deployEdition",
"summary": "Deploys a new Edition contract\n\n",
"remarks": "\n\nDeploys an Edition contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployEdition({\n name: \"My Edition\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployEdition({\n name: \"My Edition\",\n primary_sale_recipient: \"your-address\",\n});",
"unity": "await sdk\r\n .deployer\r\n .DeployEdition(new NFTContractDeployMetadata()\r\n { name = \"My Collection\", primary_sale_recipient = \"0x...\" });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata"
}
},
{
"name": "deployEditionDrop",
"summary": "Deploys a new EditionDrop contract\n\n",
"remarks": "\n\nDeploys an Edition Drop contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployEditionDrop({\n name: \"My Edition Drop\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployEditionDrop({\n name: \"My Edition Drop\",\n primary_sale_recipient: \"your-address\",\n});",
"unity": "await sdk\r\n .deployer\r\n .DeployEditionDrop(new NFTContractDeployMetadata()\r\n { name = \"My Collection\", primary_sale_recipient = \"0x...\" });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata"
}
},
{
"name": "deployLoyaltyCard",
"summary": "Deploys a new LoyaltyCard contract\n\n",
"remarks": "\n\nDeploys a LoyaltyCard contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployLoyaltyCard({\n name: \"My Loyalty Program\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployLoyaltyCard({\n name: \"My Loyalty Program\",\n primary_sale_recipient: \"your-address\",\n});"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata"
}
},
{
"name": "deployMarketplace",
"summary": "Deploys a new Marketplace contract\n\n",
"remarks": "\n\nDeploys a Marketplace contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployMarketplace({\n name: \"My Marketplace\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployMarketplace({\n name: \"My Marketplace\",\n primary_sale_recipient: \"your-address\",\n});",
"unity": "await sdk\r\n .deployer\r\n .DeployMarketplace(new MarketplaceContractDeployMetadata()\r\n { name = \"My Collection\" });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.marketplacecontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.marketplacecontractdeploymetadata"
}
},
{
"name": "deployMarketplaceV3",
"summary": "Deploys a new Marketplace-V3 contract\n\n",
"remarks": "\n\nDeploys a Marketplace-V3 contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployMarketplaceV3({\n name: \"My Marketplace\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployMarketplaceV3({\n name: \"My Marketplace\",\n primary_sale_recipient: \"your-address\",\n});"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.marketplacev3contractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.marketplacev3contractdeploymetadata"
}
},
{
"name": "deployMultiwrap",
"summary": "Deploys a new Multiwrap contract\n\n",
"remarks": "\n\nDeploys a Multiwrap contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployMultiwrap({\n name: \"My Multiwrap\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployMultiwrap({\n name: \"My Multiwrap\",\n});"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.multiwrapcontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.multiwrapcontractdeploymetadata"
}
},
{
"name": "deployNFTCollection",
"summary": "Deploys an NFT Collection contract\n\n",
"remarks": "\n\nDeploys an NFT Collection contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployNFTCollection({\n name: \"My Collection\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployNFTCollection({\n name: \"My Collection\",\n primary_sale_recipient: \"your-address\",\n});",
"unity": "await sdk\r\n .deployer\r\n .DeployNFTCollection(new NFTContractDeployMetadata()\r\n { name = \"My Collection\", primary_sale_recipient = \"0x...\" });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata"
}
},
{
"name": "deployNFTDrop",
"summary": "Deploys a new NFTDrop contract\n\n",
"remarks": "\n\nDeploys an NFT Drop contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployNFTDrop({\n name: \"My Drop\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployNFTDrop({\n name: \"My Drop\",\n primary_sale_recipient: \"your-address\",\n});",
"unity": "await sdk\r\n .deployer\r\n .DeployNFTDrop(new NFTContractDeployMetadata()\r\n { name = \"My Collection\", primary_sale_recipient = \"0x...\" });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata"
}
},
{
"name": "deployOpenEdition",
"summary": "Deploys a new OpenEditionERC721 contract\n\n",
"remarks": "\n\nDeploys a OpenEdition contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployOpenEdition({\n name: \"My Open Edition\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployOpenEdition({\n name: \"My Open Edition\",\n primary_sale_recipient: \"your-address\",\n});"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.openeditioncontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.openeditioncontractdeploymetadata"
}
},
{
"name": "deployPack",
"summary": "Deploys a new Pack contract\n\n",
"remarks": "\n\nDeploys a Pack contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deployPack({\n name: \"My Pack\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deployPack({\n name: \"My Pack\",\n primary_sale_recipient: \"your-address\",\n});",
"unity": "await sdk\r\n .deployer\r\n .DeployPack(new NFTContractDeployMetadata()\r\n { name = \"My Collection\", primary_sale_recipient = \"0x...\" });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata"
}
},
{
"name": "deploySignatureDrop",
"summary": "Deploys a new SignatureDrop contract\n\n",
"remarks": "\n\nDeploys a SignatureDrop contract and returns the address of the deployed contract\n\n",
"examples": {
"javascript": "const contractAddress = await sdk.deployer.deploySignatureDrop({\n name: \"My Signature Drop\",\n primary_sale_recipient: \"your-address\",\n});",
"python": "",
"go": "",
"react": "const sdk = useSDK();\n\nconst contractAddress = await sdk.deployer.deploySignatureDrop({\n name: \"My Signature Drop\",\n primary_sale_recipient: \"your-address\",\n});",
"unity": "await sdk\r\n .deployer\r\n .DeploySignatureDrop(new NFTContractDeployMetadata()\r\n { name = \"My Collection\", primary_sale_recipient = \"0x...\" });"
},
"reference": {
"javascript": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata",
"python": "",
"go": "",
"react": "https://portal.thirdweb.com/typescript/sdk.nftcontractdeploymetadata"
}