create-stylus 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-stylus",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "author": "Q3 Labs",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ss",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": true,
5
5
  "workspaces": {
6
6
  "packages": [
@@ -2,7 +2,7 @@
2
2
  * This file is autogenerated by scaffold-stylus.
3
3
  * You should not edit it manually or your changes might be overwritten.
4
4
  */
5
- import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
5
+ import { GenericContractsDeclaration } from "../utils/scaffold-eth/contract";
6
6
 
7
7
  const deployedContracts = {} as const;
8
8
 
@@ -297,7 +297,7 @@ checksum = "64b728d511962dda67c1bc7ea7c03736ec275ed2cf4c35d9585298ac9ccf3b73"
297
297
  dependencies = [
298
298
  "proc-macro2",
299
299
  "quote",
300
- "syn 2.0.105",
300
+ "syn 2.0.106",
301
301
  ]
302
302
 
303
303
  [[package]]
@@ -391,7 +391,7 @@ dependencies = [
391
391
  "proc-macro-error2",
392
392
  "proc-macro2",
393
393
  "quote",
394
- "syn 2.0.105",
394
+ "syn 2.0.106",
395
395
  ]
396
396
 
397
397
  [[package]]
@@ -407,7 +407,7 @@ dependencies = [
407
407
  "proc-macro-error2",
408
408
  "proc-macro2",
409
409
  "quote",
410
- "syn 2.0.105",
410
+ "syn 2.0.106",
411
411
  "syn-solidity",
412
412
  "tiny-keccak",
413
413
  ]
@@ -424,7 +424,7 @@ dependencies = [
424
424
  "macro-string",
425
425
  "proc-macro2",
426
426
  "quote",
427
- "syn 2.0.105",
427
+ "syn 2.0.106",
428
428
  "syn-solidity",
429
429
  ]
430
430
 
@@ -712,18 +712,18 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d"
712
712
  dependencies = [
713
713
  "proc-macro2",
714
714
  "quote",
715
- "syn 2.0.105",
715
+ "syn 2.0.106",
716
716
  ]
717
717
 
718
718
  [[package]]
719
719
  name = "async-trait"
720
- version = "0.1.88"
720
+ version = "0.1.89"
721
721
  source = "registry+https://github.com/rust-lang/crates.io-index"
722
- checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5"
722
+ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb"
723
723
  dependencies = [
724
724
  "proc-macro2",
725
725
  "quote",
726
- "syn 2.0.105",
726
+ "syn 2.0.106",
727
727
  ]
728
728
 
729
729
  [[package]]
@@ -745,7 +745,7 @@ checksum = "ffdcb70bdbc4d478427380519163274ac86e52916e10f0a8889adf0f96d3fee7"
745
745
  dependencies = [
746
746
  "proc-macro2",
747
747
  "quote",
748
- "syn 2.0.105",
748
+ "syn 2.0.106",
749
749
  ]
750
750
 
751
751
  [[package]]
@@ -995,9 +995,9 @@ dependencies = [
995
995
 
996
996
  [[package]]
997
997
  name = "cc"
998
- version = "1.2.32"
998
+ version = "1.2.33"
999
999
  source = "registry+https://github.com/rust-lang/crates.io-index"
1000
- checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e"
1000
+ checksum = "3ee0f8803222ba5a7e2777dd72ca451868909b1ac410621b676adf07280e9b5f"
1001
1001
  dependencies = [
1002
1002
  "jobserver",
1003
1003
  "libc",
@@ -1060,7 +1060,7 @@ dependencies = [
1060
1060
  "heck",
1061
1061
  "proc-macro2",
1062
1062
  "quote",
1063
- "syn 2.0.105",
1063
+ "syn 2.0.106",
1064
1064
  ]
1065
1065
 
1066
1066
  [[package]]
@@ -1197,6 +1197,20 @@ version = "0.8.7"
1197
1197
  source = "registry+https://github.com/rust-lang/crates.io-index"
1198
1198
  checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
1199
1199
 
1200
+ [[package]]
1201
+ name = "counter"
1202
+ version = "0.1.11"
1203
+ dependencies = [
1204
+ "alloy-primitives",
1205
+ "alloy-sol-types",
1206
+ "dotenv",
1207
+ "ethers",
1208
+ "eyre",
1209
+ "hex",
1210
+ "stylus-sdk",
1211
+ "tokio",
1212
+ ]
1213
+
1200
1214
  [[package]]
1201
1215
  name = "cpufeatures"
1202
1216
  version = "0.2.17"
@@ -1359,7 +1373,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
1359
1373
  dependencies = [
1360
1374
  "proc-macro2",
1361
1375
  "quote",
1362
- "syn 2.0.105",
1376
+ "syn 2.0.106",
1363
1377
  "unicode-xid",
1364
1378
  ]
1365
1379
 
@@ -1434,7 +1448,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
1434
1448
  dependencies = [
1435
1449
  "proc-macro2",
1436
1450
  "quote",
1437
- "syn 2.0.105",
1451
+ "syn 2.0.106",
1438
1452
  ]
1439
1453
 
1440
1454
  [[package]]
@@ -1682,7 +1696,7 @@ dependencies = [
1682
1696
  "reqwest 0.11.27",
1683
1697
  "serde",
1684
1698
  "serde_json",
1685
- "syn 2.0.105",
1699
+ "syn 2.0.106",
1686
1700
  "toml 0.8.23",
1687
1701
  "walkdir",
1688
1702
  ]
@@ -1700,7 +1714,7 @@ dependencies = [
1700
1714
  "proc-macro2",
1701
1715
  "quote",
1702
1716
  "serde_json",
1703
- "syn 2.0.105",
1717
+ "syn 2.0.106",
1704
1718
  ]
1705
1719
 
1706
1720
  [[package]]
@@ -1726,7 +1740,7 @@ dependencies = [
1726
1740
  "serde",
1727
1741
  "serde_json",
1728
1742
  "strum 0.26.3",
1729
- "syn 2.0.105",
1743
+ "syn 2.0.106",
1730
1744
  "tempfile",
1731
1745
  "thiserror 1.0.69",
1732
1746
  "tiny-keccak",
@@ -2058,7 +2072,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
2058
2072
  dependencies = [
2059
2073
  "proc-macro2",
2060
2074
  "quote",
2061
- "syn 2.0.105",
2075
+ "syn 2.0.106",
2062
2076
  ]
2063
2077
 
2064
2078
  [[package]]
@@ -2577,7 +2591,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9"
2577
2591
  dependencies = [
2578
2592
  "proc-macro2",
2579
2593
  "quote",
2580
- "syn 2.0.105",
2594
+ "syn 2.0.106",
2581
2595
  ]
2582
2596
 
2583
2597
  [[package]]
@@ -2857,7 +2871,7 @@ checksum = "1b27834086c65ec3f9387b096d66e99f221cf081c2b738042aa252bcd41204e3"
2857
2871
  dependencies = [
2858
2872
  "proc-macro2",
2859
2873
  "quote",
2860
- "syn 2.0.105",
2874
+ "syn 2.0.106",
2861
2875
  ]
2862
2876
 
2863
2877
  [[package]]
@@ -2998,7 +3012,7 @@ dependencies = [
2998
3012
  "proc-macro-crate",
2999
3013
  "proc-macro2",
3000
3014
  "quote",
3001
- "syn 2.0.105",
3015
+ "syn 2.0.106",
3002
3016
  ]
3003
3017
 
3004
3018
  [[package]]
@@ -3081,7 +3095,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
3081
3095
  dependencies = [
3082
3096
  "proc-macro2",
3083
3097
  "quote",
3084
- "syn 2.0.105",
3098
+ "syn 2.0.106",
3085
3099
  ]
3086
3100
 
3087
3101
  [[package]]
@@ -3133,7 +3147,7 @@ dependencies = [
3133
3147
  "proc-macro-crate",
3134
3148
  "proc-macro2",
3135
3149
  "quote",
3136
- "syn 2.0.105",
3150
+ "syn 2.0.106",
3137
3151
  ]
3138
3152
 
3139
3153
  [[package]]
@@ -3280,7 +3294,7 @@ dependencies = [
3280
3294
  "phf_shared",
3281
3295
  "proc-macro2",
3282
3296
  "quote",
3283
- "syn 2.0.105",
3297
+ "syn 2.0.106",
3284
3298
  ]
3285
3299
 
3286
3300
  [[package]]
@@ -3309,7 +3323,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
3309
3323
  dependencies = [
3310
3324
  "proc-macro2",
3311
3325
  "quote",
3312
- "syn 2.0.105",
3326
+ "syn 2.0.106",
3313
3327
  ]
3314
3328
 
3315
3329
  [[package]]
@@ -3377,7 +3391,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
3377
3391
  checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2"
3378
3392
  dependencies = [
3379
3393
  "proc-macro2",
3380
- "syn 2.0.105",
3394
+ "syn 2.0.106",
3381
3395
  ]
3382
3396
 
3383
3397
  [[package]]
@@ -3446,7 +3460,7 @@ dependencies = [
3446
3460
  "proc-macro-error-attr2",
3447
3461
  "proc-macro2",
3448
3462
  "quote",
3449
- "syn 2.0.105",
3463
+ "syn 2.0.106",
3450
3464
  ]
3451
3465
 
3452
3466
  [[package]]
@@ -3984,7 +3998,7 @@ dependencies = [
3984
3998
  "proc-macro-crate",
3985
3999
  "proc-macro2",
3986
4000
  "quote",
3987
- "syn 2.0.105",
4001
+ "syn 2.0.106",
3988
4002
  ]
3989
4003
 
3990
4004
  [[package]]
@@ -4117,7 +4131,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
4117
4131
  dependencies = [
4118
4132
  "proc-macro2",
4119
4133
  "quote",
4120
- "syn 2.0.105",
4134
+ "syn 2.0.106",
4121
4135
  ]
4122
4136
 
4123
4137
  [[package]]
@@ -4370,7 +4384,7 @@ dependencies = [
4370
4384
  "proc-macro2",
4371
4385
  "quote",
4372
4386
  "rustversion",
4373
- "syn 2.0.105",
4387
+ "syn 2.0.106",
4374
4388
  ]
4375
4389
 
4376
4390
  [[package]]
@@ -4382,7 +4396,7 @@ dependencies = [
4382
4396
  "heck",
4383
4397
  "proc-macro2",
4384
4398
  "quote",
4385
- "syn 2.0.105",
4399
+ "syn 2.0.106",
4386
4400
  ]
4387
4401
 
4388
4402
  [[package]]
@@ -4397,20 +4411,6 @@ dependencies = [
4397
4411
  "dyn-clone",
4398
4412
  ]
4399
4413
 
4400
- [[package]]
4401
- name = "stylus-hello-world"
4402
- version = "0.1.11"
4403
- dependencies = [
4404
- "alloy-primitives",
4405
- "alloy-sol-types",
4406
- "dotenv",
4407
- "ethers",
4408
- "eyre",
4409
- "hex",
4410
- "stylus-sdk",
4411
- "tokio",
4412
- ]
4413
-
4414
4414
  [[package]]
4415
4415
  name = "stylus-proc"
4416
4416
  version = "0.9.0"
@@ -4427,7 +4427,7 @@ dependencies = [
4427
4427
  "quote",
4428
4428
  "regex",
4429
4429
  "sha3",
4430
- "syn 2.0.105",
4430
+ "syn 2.0.106",
4431
4431
  "syn-solidity",
4432
4432
  "trybuild",
4433
4433
  ]
@@ -4507,9 +4507,9 @@ dependencies = [
4507
4507
 
4508
4508
  [[package]]
4509
4509
  name = "syn"
4510
- version = "2.0.105"
4510
+ version = "2.0.106"
4511
4511
  source = "registry+https://github.com/rust-lang/crates.io-index"
4512
- checksum = "7bc3fcb250e53458e712715cf74285c1f889686520d79294a9ef3bd7aa1fc619"
4512
+ checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
4513
4513
  dependencies = [
4514
4514
  "proc-macro2",
4515
4515
  "quote",
@@ -4525,7 +4525,7 @@ dependencies = [
4525
4525
  "paste",
4526
4526
  "proc-macro2",
4527
4527
  "quote",
4528
- "syn 2.0.105",
4528
+ "syn 2.0.106",
4529
4529
  ]
4530
4530
 
4531
4531
  [[package]]
@@ -4551,7 +4551,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
4551
4551
  dependencies = [
4552
4552
  "proc-macro2",
4553
4553
  "quote",
4554
- "syn 2.0.105",
4554
+ "syn 2.0.106",
4555
4555
  ]
4556
4556
 
4557
4557
  [[package]]
@@ -4646,7 +4646,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
4646
4646
  dependencies = [
4647
4647
  "proc-macro2",
4648
4648
  "quote",
4649
- "syn 2.0.105",
4649
+ "syn 2.0.106",
4650
4650
  ]
4651
4651
 
4652
4652
  [[package]]
@@ -4657,7 +4657,7 @@ checksum = "cc5b44b4ab9c2fdd0e0512e6bece8388e214c0749f5862b114cc5b7a25daf227"
4657
4657
  dependencies = [
4658
4658
  "proc-macro2",
4659
4659
  "quote",
4660
- "syn 2.0.105",
4660
+ "syn 2.0.106",
4661
4661
  ]
4662
4662
 
4663
4663
  [[package]]
@@ -4762,7 +4762,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
4762
4762
  dependencies = [
4763
4763
  "proc-macro2",
4764
4764
  "quote",
4765
- "syn 2.0.105",
4765
+ "syn 2.0.106",
4766
4766
  ]
4767
4767
 
4768
4768
  [[package]]
@@ -4969,7 +4969,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
4969
4969
  dependencies = [
4970
4970
  "proc-macro2",
4971
4971
  "quote",
4972
- "syn 2.0.105",
4972
+ "syn 2.0.106",
4973
4973
  ]
4974
4974
 
4975
4975
  [[package]]
@@ -5214,7 +5214,7 @@ dependencies = [
5214
5214
  "log",
5215
5215
  "proc-macro2",
5216
5216
  "quote",
5217
- "syn 2.0.105",
5217
+ "syn 2.0.106",
5218
5218
  "wasm-bindgen-shared",
5219
5219
  ]
5220
5220
 
@@ -5249,7 +5249,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
5249
5249
  dependencies = [
5250
5250
  "proc-macro2",
5251
5251
  "quote",
5252
- "syn 2.0.105",
5252
+ "syn 2.0.106",
5253
5253
  "wasm-bindgen-backend",
5254
5254
  "wasm-bindgen-shared",
5255
5255
  ]
@@ -5640,7 +5640,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
5640
5640
  dependencies = [
5641
5641
  "proc-macro2",
5642
5642
  "quote",
5643
- "syn 2.0.105",
5643
+ "syn 2.0.106",
5644
5644
  "synstructure",
5645
5645
  ]
5646
5646
 
@@ -5661,7 +5661,7 @@ checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
5661
5661
  dependencies = [
5662
5662
  "proc-macro2",
5663
5663
  "quote",
5664
- "syn 2.0.105",
5664
+ "syn 2.0.106",
5665
5665
  ]
5666
5666
 
5667
5667
  [[package]]
@@ -5681,7 +5681,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
5681
5681
  dependencies = [
5682
5682
  "proc-macro2",
5683
5683
  "quote",
5684
- "syn 2.0.105",
5684
+ "syn 2.0.106",
5685
5685
  "synstructure",
5686
5686
  ]
5687
5687
 
@@ -5702,7 +5702,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
5702
5702
  dependencies = [
5703
5703
  "proc-macro2",
5704
5704
  "quote",
5705
- "syn 2.0.105",
5705
+ "syn 2.0.106",
5706
5706
  ]
5707
5707
 
5708
5708
  [[package]]
@@ -5735,7 +5735,7 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f"
5735
5735
  dependencies = [
5736
5736
  "proc-macro2",
5737
5737
  "quote",
5738
- "syn 2.0.105",
5738
+ "syn 2.0.106",
5739
5739
  ]
5740
5740
 
5741
5741
  [[package]]
@@ -1,5 +1,5 @@
1
1
  [package]
2
- name = "stylus-hello-world"
2
+ name = "counter"
3
3
  version = "0.1.11"
4
4
  edition = "2021"
5
5
  license = "MIT OR Apache-2.0"
@@ -29,7 +29,7 @@ debug = ["stylus-sdk/debug"]
29
29
  mini-alloc = ["stylus-sdk/mini-alloc"]
30
30
 
31
31
  [[bin]]
32
- name = "stylus-hello-world"
32
+ name = "counter"
33
33
  path = "src/main.rs"
34
34
 
35
35
  [lib]
@@ -1,2 +1,2 @@
1
1
  [toolchain]
2
- channel = "1.87.0"
2
+ channel = "1.89.0"
@@ -6,5 +6,5 @@ pub extern "C" fn main() {}
6
6
 
7
7
  #[cfg(feature = "export-abi")]
8
8
  fn main() {
9
- stylus_hello_world::print_from_args();
9
+ counter::print_from_args();
10
10
  }
@@ -1,5 +1,9 @@
1
1
  import deployStylusContract from "./deploy_contract";
2
- import { getDeploymentConfig, printDeployedAddresses } from "./utils/";
2
+ import {
3
+ getDeploymentConfig,
4
+ getRpcUrlFromChain,
5
+ printDeployedAddresses,
6
+ } from "./utils/";
3
7
  import { DeployOptions } from "./utils/type";
4
8
  import { config as dotenvConfig } from "dotenv";
5
9
  import * as path from "path";
@@ -16,7 +20,7 @@ if (fs.existsSync(envPath)) {
16
20
  export default async function deployScript(deployOptions: DeployOptions) {
17
21
  const config = getDeploymentConfig(deployOptions);
18
22
 
19
- console.log(`📡 Using endpoint: ${config.chain?.rpcUrl}`);
23
+ console.log(`📡 Using endpoint: ${getRpcUrlFromChain(config.chain)}`);
20
24
  if (config.chain) {
21
25
  console.log(`🌐 Network: ${config.chain?.name}`);
22
26
  console.log(`🔗 Chain ID: ${config.chain?.id}`);
@@ -50,5 +54,5 @@ export default async function deployScript(deployOptions: DeployOptions) {
50
54
 
51
55
  // Print the deployed addresses
52
56
  console.log("\n\n");
53
- printDeployedAddresses(config.deploymentDir, config.chain?.id);
57
+ printDeployedAddresses(config.deploymentDir, config.chain.id.toString());
54
58
  }
@@ -4,17 +4,18 @@ import {
4
4
  executeCommand,
5
5
  extractDeploymentInfo,
6
6
  saveDeployment,
7
- ORBIT_CHAINS,
7
+ getBlockExplorerUrlFromChain,
8
+ getRpcUrlFromChain,
9
+ getContractData,
10
+ contractHasInitializeFunction,
8
11
  // estimateGasPrice,
9
12
  } from "./utils/";
10
13
  import { exportStylusAbi } from "./export_abi";
11
14
  import { DeployOptions } from "./utils/type";
12
15
  import { buildDeployCommand } from "./utils/command";
13
- import { Chain, createPublicClient, createWalletClient, http } from "viem";
16
+ import { Abi, createPublicClient, createWalletClient, http } from "viem";
14
17
  import { privateKeyToAccount } from "viem/accounts";
15
-
16
18
  import { arbitrumNitro } from "../../nextjs/utils/scaffold-stylus/supportedChains";
17
- import deployedContracts from "../../nextjs/contracts/deployedContracts";
18
19
 
19
20
  /**
20
21
  * Deploy a single contract using cargo stylus
@@ -50,8 +51,20 @@ export default async function deployStylusContract(
50
51
  // Extract the actual deployed address from the output
51
52
  const deploymentInfo = extractDeploymentInfo(deployOutput);
52
53
  if (deploymentInfo) {
53
- console.log(`📋 Contract deployed at address: ${deploymentInfo.address}`);
54
- console.log("Transaction hash: ", deploymentInfo.txHash);
54
+ const blockExplorerUrl = getBlockExplorerUrlFromChain(config.chain);
55
+ if (blockExplorerUrl) {
56
+ console.log(
57
+ `📋 Contract deployed: ${blockExplorerUrl}/address/${deploymentInfo.address}`,
58
+ );
59
+ console.log(
60
+ `Transaction hash: ${blockExplorerUrl}/tx/${deploymentInfo.txHash}`,
61
+ );
62
+ } else {
63
+ console.log(
64
+ `📋 Contract deployed at address: ${deploymentInfo.address}`,
65
+ );
66
+ console.log("Transaction hash: ", deploymentInfo.txHash);
67
+ }
55
68
  } else {
56
69
  throw new Error("Failed to extract deployed address");
57
70
  }
@@ -64,32 +77,29 @@ export default async function deployStylusContract(
64
77
  config.contractFolder,
65
78
  config.contractName,
66
79
  false,
67
- config.chain?.id,
80
+ config.chain.id.toString(),
81
+ );
82
+
83
+ // Get contract data from deployed contracts after ABI export
84
+ const contractData = getContractData(
85
+ config.chain.id.toString(),
86
+ config.contractName,
68
87
  );
69
88
 
70
89
  // Call the initialize function if orbit deployment
71
90
  if (
72
91
  !!deployOptions.isOrbit &&
73
- config.chain?.id !== arbitrumNitro?.id.toString()
92
+ config.chain.id !== arbitrumNitro.id &&
93
+ contractHasInitializeFunction(contractData)
74
94
  ) {
75
- const orbitChain = ORBIT_CHAINS.find(
76
- (chain) => chain.id.toString() === config.chain?.id,
77
- );
78
-
79
- if (!orbitChain) {
80
- throw new Error(
81
- `Chain ${config.chain?.id} is not supported for orbit deployment`,
82
- );
83
- }
84
-
85
95
  const publicClient = createPublicClient({
86
- chain: orbitChain as unknown as Chain,
96
+ chain: config.chain,
87
97
  transport: http(),
88
98
  });
89
99
 
90
100
  // need wallet client to sign the transaction
91
101
  const walletClient = createWalletClient({
92
- chain: orbitChain as unknown as Chain,
102
+ chain: config.chain,
93
103
  transport: http(),
94
104
  });
95
105
 
@@ -98,35 +108,44 @@ export default async function deployStylusContract(
98
108
  const { request } = await publicClient.simulateContract({
99
109
  account,
100
110
  address: deploymentInfo.address,
101
- // @ts-expect-error deployed contract is empty at the beginning
102
- abi: deployedContracts[config.chain.id][config.contractName].abi,
111
+ abi: contractData.abi as Abi,
103
112
  functionName: "initialize",
104
- args: deployOptions.constructorArgs,
113
+ args: deployOptions.constructorArgs as any[],
105
114
  });
106
115
 
107
116
  const initTxHash = await walletClient.writeContract(request);
108
117
 
109
118
  console.log("Initialize transaction hash: ", initTxHash);
119
+ } else {
120
+ console.log("\nContract does not have an initialize function");
121
+ console.log("Skipping initialization");
110
122
  }
111
123
 
112
124
  // Step 3: Verify the contract
113
125
  if (deployOptions.verify) {
114
126
  try {
115
127
  const output = await executeCommand(
116
- `cargo stylus verify --endpoint=${config.chain?.rpcUrl} --deployment-tx=${deploymentInfo.txHash}`,
128
+ `cargo stylus verify --endpoint=${getRpcUrlFromChain(config.chain)} --deployment-tx=${deploymentInfo.txHash}`,
117
129
  deployOptions.contract!,
118
130
  "Verifying contract with cargo stylus",
119
131
  );
120
132
  console.log(output);
121
133
  } catch (error) {
122
- console.error(
123
- `❌ Verification failed in: ${deployOptions.contract}`,
124
- error,
125
- );
134
+ console.error(`❌ Verification failed in: ${deployOptions.contract}`);
135
+ if (error instanceof Error) {
136
+ console.error(error.message);
137
+ } else {
138
+ console.error(error);
139
+ }
126
140
  }
127
141
  }
128
142
  } catch (error) {
129
- console.error(`❌ Deployment failed in: ${deployOptions.contract}`, error);
143
+ console.error(`❌ Deployment failed in: ${deployOptions.contract}`);
144
+ if (error instanceof Error) {
145
+ console.error(error.message);
146
+ } else {
147
+ console.error(error);
148
+ }
130
149
  process.exit(1);
131
150
  }
132
151
  }
@@ -1,4 +1,4 @@
1
- import { getChain } from "./utils/";
1
+ import { getChain, getRpcUrlFromChain } from "./utils/";
2
2
  import { SUPPORTED_NETWORKS } from "./utils/";
3
3
 
4
4
  function testNetworkFunctionality() {
@@ -9,7 +9,7 @@ function testNetworkFunctionality() {
9
9
  testNetworks.forEach((network) => {
10
10
  const chain = getChain(network);
11
11
  if (chain) {
12
- console.log(`✅ ${network}: ${chain.rpcUrl}`);
12
+ console.log(`✅ ${network}: ${getRpcUrlFromChain(chain)}`);
13
13
  } else {
14
14
  console.log(`❌ ${network}: Not found in viem chains`);
15
15
  }
@@ -1,25 +1,39 @@
1
1
  import { spawn } from "child_process";
2
2
  import { DeploymentConfig, DeployOptions } from "./type";
3
- import { extractGasPriceFromOutput } from "./contract";
3
+ import {
4
+ extractGasPriceFromOutput,
5
+ isContractHasConstructor,
6
+ } from "./contract";
7
+ import { getRpcUrlFromChain } from "./network";
4
8
 
5
9
  export async function buildDeployCommand(
6
10
  config: DeploymentConfig,
7
11
  deployOptions: DeployOptions,
8
12
  ) {
9
- let baseCommand = `cargo stylus deploy --endpoint='${config.chain?.rpcUrl}' --private-key='${config.privateKey}'`;
13
+ let baseCommand = `cargo stylus deploy --endpoint='${getRpcUrlFromChain(config.chain)}' --private-key='${config.privateKey}'`;
10
14
 
11
15
  if (deployOptions.estimateGas) {
12
16
  return `${baseCommand} --estimate-gas`;
13
17
  }
14
18
 
15
- if (!deployOptions.verify) {
16
- baseCommand += ` --no-verify`;
17
- }
18
-
19
19
  if (deployOptions.maxFee) {
20
20
  baseCommand += ` --max-fee-per-gas-gwei=${deployOptions.maxFee}`;
21
21
  }
22
22
 
23
+ if (!deployOptions.verify) {
24
+ baseCommand += ` --no-verify`;
25
+ } else {
26
+ if (
27
+ deployOptions.constructorArgs &&
28
+ deployOptions.constructorArgs.length > 0 &&
29
+ isContractHasConstructor(config.contractFolder)
30
+ ) {
31
+ throw new Error(
32
+ "Verification is not currently supported with constructors. Please implement and use initialize() function to initialize your contracts: Refer to readme.md for tutorial",
33
+ );
34
+ }
35
+ }
36
+
23
37
  if (
24
38
  deployOptions.constructorArgs &&
25
39
  deployOptions.constructorArgs.length > 0 &&
@@ -35,7 +49,7 @@ export async function estimateGasPrice(
35
49
  config: DeploymentConfig,
36
50
  deployOptions: DeployOptions,
37
51
  ): Promise<string> {
38
- let deployCommand = `cargo stylus deploy --endpoint='${config.chain?.rpcUrl}' --private-key='${config.privateKey}' --no-verify --estimate-gas `;
52
+ let deployCommand = `cargo stylus deploy --endpoint='${getRpcUrlFromChain(config.chain)}' --private-key='${config.privateKey}' --no-verify --estimate-gas `;
39
53
  if (deployOptions.constructorArgs) {
40
54
  deployCommand += ` --constructor-args='${deployOptions.constructorArgs.join(" ")}'`;
41
55
  }
@@ -72,7 +86,6 @@ export function executeCommand(
72
86
 
73
87
  let output = "";
74
88
  let errorOutput = "";
75
- const outputLines: string[] = [];
76
89
  let errorLines: string[] = [];
77
90
 
78
91
  // Handle stdout
@@ -80,8 +93,6 @@ export function executeCommand(
80
93
  childProcess.stdout.on("data", (data: Buffer) => {
81
94
  const chunk = data.toString();
82
95
  output += chunk;
83
- const newLines = chunk.split("\n");
84
- outputLines.push(...newLines);
85
96
  });
86
97
  }
87
98
 
@@ -92,53 +103,37 @@ export function executeCommand(
92
103
  errorOutput += chunk;
93
104
  const newLines = chunk.split("\n");
94
105
  errorLines.push(...newLines);
95
- // Keep only the last 5 lines
96
- if (errorLines.length > 5) {
97
- errorLines = errorLines.slice(-5);
106
+ // Keep only the last 20 lines, just for safety
107
+ if (errorLines.length > 20) {
108
+ errorLines = errorLines.slice(-20);
98
109
  }
99
110
  });
100
111
  }
101
112
 
102
113
  // Handle process completion
103
114
  childProcess.on("close", (code: number | null) => {
104
- if (code === 0) {
115
+ // this can extract and detect errors from docker logs because it not throw error code
116
+ const errors = extractErrorLines(errorLines);
117
+
118
+ if (code === 0 && !errors) {
105
119
  console.log(`\n✅ ${description} completed successfully!`);
106
120
  resolve(output);
107
121
  } else {
108
122
  console.error(`\n❌ ${description} failed with exit code ${code}`);
109
123
  // Print error output starting from "project metadata hash computed on deployment" or error patterns, or all logs if not found
110
- if (errorLines.length > 0) {
111
- const metadataIndex = errorLines.findIndex((line) =>
112
- line.includes("project metadata hash computed on deployment"),
113
- );
114
- const errorIndex = errorLines.findIndex((line) =>
115
- line.includes("error["),
116
- );
117
-
118
- let startIndex = -1;
119
- if (metadataIndex >= 0) {
120
- startIndex = metadataIndex;
121
- } else if (errorIndex >= 0) {
122
- startIndex = errorIndex;
124
+ if (errors) {
125
+ console.error(errors);
126
+ if (
127
+ !command.includes("--no-verify") &&
128
+ errors.includes("mismatch number of constructor arguments")
129
+ ) {
130
+ errorOutput += `\nCan not verify contract with constructor arguments.\n`;
123
131
  }
124
-
125
- if (startIndex >= 0) {
126
- const linesToPrint = errorLines.slice(startIndex);
127
- linesToPrint.forEach((line) => {
128
- if (line.trim()) console.error(line);
129
- });
130
- } else {
131
- errorLines.forEach((line) => {
132
- if (line.trim()) console.error(line);
133
- });
134
- }
135
- }
136
- if (errorOutput) {
137
- console.error(errorOutput);
138
132
  }
133
+
139
134
  reject(
140
135
  new Error(
141
- `Command failed with exit code ${code}. Error output: ${errorOutput}`,
136
+ `Command failed with exit code ${code}. Error output: \n${errorOutput}`,
142
137
  ),
143
138
  );
144
139
  }
@@ -151,3 +146,35 @@ export function executeCommand(
151
146
  });
152
147
  });
153
148
  }
149
+
150
+ function extractErrorLines(errorLines: string[]): string | null {
151
+ let output: string = "";
152
+ if (errorLines.length > 0) {
153
+ const metadataIndex = errorLines.findIndex((line) =>
154
+ line.includes("project metadata hash computed on deployment"),
155
+ );
156
+ const errorIndex = errorLines.findIndex(
157
+ (line) =>
158
+ line.toLowerCase().includes("error[") ||
159
+ line.toLowerCase().includes("error:"),
160
+ );
161
+
162
+ let startIndex = -1;
163
+ if (metadataIndex >= 0) {
164
+ startIndex = metadataIndex;
165
+ } else if (errorIndex >= 0) {
166
+ startIndex = errorIndex;
167
+ }
168
+
169
+ if (startIndex === -1) {
170
+ return null;
171
+ }
172
+
173
+ const linesToPrint = errorLines.slice(startIndex);
174
+ linesToPrint.forEach((line) => {
175
+ if (line.trim()) output += line + "\n";
176
+ });
177
+ return output;
178
+ }
179
+ return null;
180
+ }
@@ -12,6 +12,7 @@ export const generatedContractComment = `
12
12
  * This file is autogenerated by scaffold-stylus.
13
13
  * You should not edit it manually or your changes might be overwritten.
14
14
  */
15
+ import { GenericContractsDeclaration } from "../utils/scaffold-eth/contract";
15
16
  `;
16
17
 
17
18
  /**
@@ -40,6 +41,15 @@ export function getContractNameFromCargoToml(contractFolder: string): string {
40
41
  return parsed.package.name;
41
42
  }
42
43
 
44
+ export function isContractHasConstructor(contractFolder: string): boolean {
45
+ const contractPath = path.resolve(contractFolder, "src/lib.rs");
46
+ if (!fs.existsSync(contractPath)) {
47
+ throw new Error(`lib.rs not found in contract folder: ${contractPath}`);
48
+ }
49
+ const contractContent = fs.readFileSync(contractPath, "utf8");
50
+ return contractContent.includes("#[constructor]");
51
+ }
52
+
43
53
  export function getExportConfig(
44
54
  contractFolder?: string,
45
55
  contractName?: string,
@@ -175,7 +185,7 @@ export async function generateTsAbi(
175
185
 
176
186
  const contractsString = JSON.stringify(deployedContractsObj, null, 2);
177
187
 
178
- const output = `${fileHeader}const deployedContracts = ${contractsString} as const;\n\nexport default deployedContracts;\n`;
188
+ const output = `${fileHeader}const deployedContracts = ${contractsString} as const;\n\nexport default deployedContracts satisfies GenericContractsDeclaration;\n`;
179
189
 
180
190
  if (!fs.existsSync(TARGET_DIR)) {
181
191
  fs.mkdirSync(TARGET_DIR);
@@ -224,3 +234,61 @@ export function handleSolcError(
224
234
  console.error("\n💡 Please check the error details above and try again.");
225
235
  }
226
236
  }
237
+
238
+ /**
239
+ * Dynamically load deployed contracts from the TypeScript file
240
+ * This is useful when the file has been updated during runtime
241
+ * @returns The deployed contracts object
242
+ */
243
+ export function loadDeployedContracts(): any {
244
+ const deployedContractsPath = "../nextjs/contracts/deployedContracts.ts";
245
+
246
+ if (!fs.existsSync(deployedContractsPath)) {
247
+ throw new Error("deployedContracts.ts file not found");
248
+ }
249
+
250
+ const fileContent = fs.readFileSync(deployedContractsPath, "utf8");
251
+ const match = fileContent.match(
252
+ /const deployedContracts = ([\s\S]*?) as const;/,
253
+ );
254
+
255
+ if (!match) {
256
+ throw new Error("Could not parse deployedContracts.ts file");
257
+ }
258
+
259
+ // eslint-disable-next-line no-eval
260
+ return eval("(" + match[1] + ")");
261
+ }
262
+
263
+ /**
264
+ * Get contract data from deployed contracts
265
+ * @param chainId - The chain ID
266
+ * @param contractName - The contract name
267
+ * @returns The contract data with address, txHash, and abi
268
+ */
269
+ export function getContractData(chainId: string, contractName: string): any {
270
+ const deployedContracts = loadDeployedContracts();
271
+
272
+ if (
273
+ !deployedContracts ||
274
+ !deployedContracts[chainId] ||
275
+ !deployedContracts[chainId][contractName]
276
+ ) {
277
+ throw new Error(
278
+ `Contract ${contractName} not found in deployedContracts for chain ${chainId}`,
279
+ );
280
+ }
281
+
282
+ const contractData = deployedContracts[chainId][contractName];
283
+ if (!contractData.abi) {
284
+ throw new Error(
285
+ `ABI not found for contract ${contractName} on chain ${chainId}`,
286
+ );
287
+ }
288
+
289
+ return contractData;
290
+ }
291
+
292
+ export function contractHasInitializeFunction(contractData: any): boolean {
293
+ return contractData.abi.some((abi: any) => abi.name === "initialize");
294
+ }
@@ -10,7 +10,6 @@ import {
10
10
  import * as path from "path";
11
11
  import * as fs from "fs";
12
12
  import { config as dotenvConfig } from "dotenv";
13
- import { SupportedNetworkMinimal } from "./type";
14
13
 
15
14
  const envPath = path.resolve(__dirname, "../../.env");
16
15
  if (fs.existsSync(envPath)) {
@@ -24,7 +23,7 @@ export const SUPPORTED_NETWORKS: Record<string, Chain> = {
24
23
  arbitrumNova: arbitrumNova as Chain,
25
24
  eduChainTestnet: eduChainTestnet as unknown as Chain,
26
25
  eduChain: eduChain as unknown as Chain,
27
- superposition: superposition as Chain,
26
+ superposition: superposition as unknown as Chain,
28
27
  superpositionTestnet: superpositionTestnet as Chain,
29
28
  };
30
29
 
@@ -43,11 +42,11 @@ export const ALIASES: Record<string, string> = {
43
42
  export const ORBIT_CHAINS: Chain[] = [
44
43
  eduChain as unknown as Chain,
45
44
  eduChainTestnet as unknown as Chain,
46
- superposition as Chain,
45
+ superposition as unknown as Chain,
47
46
  superpositionTestnet as Chain,
48
47
  ];
49
48
 
50
- export function getChain(networkName: string): SupportedNetworkMinimal | null {
49
+ export function getChain(networkName: string): Chain | null {
51
50
  try {
52
51
  const actualNetworkName = ALIASES[networkName.toLowerCase()] || networkName;
53
52
 
@@ -55,14 +54,7 @@ export function getChain(networkName: string): SupportedNetworkMinimal | null {
55
54
  ([key]) => key.toLowerCase() === actualNetworkName.toLowerCase(),
56
55
  );
57
56
 
58
- if (chainEntry) {
59
- return {
60
- name: chainEntry[0],
61
- alias: getAliasFromNetworkName(chainEntry[0]),
62
- id: chainEntry[1].id.toString(),
63
- rpcUrl: getRpcUrlFromChain(chainEntry[1]),
64
- };
65
- }
57
+ if (chainEntry) return chainEntry[1];
66
58
 
67
59
  const supportedNetworks = Object.keys(SUPPORTED_NETWORKS);
68
60
  console.warn(
@@ -131,6 +123,7 @@ export function getPrivateKey(networkName: string): string {
131
123
 
132
124
  export const getAccountAddress = (networkName: string): Address | undefined => {
133
125
  const actualNetworkName = ALIASES[networkName.toLowerCase()] || networkName;
126
+
134
127
  switch (actualNetworkName.toLowerCase()) {
135
128
  case "arbitrum":
136
129
  return process.env["ACCOUNT_ADDRESS_MAINNET"] as Address;
@@ -154,7 +147,7 @@ export const getAccountAddress = (networkName: string): Address | undefined => {
154
147
  }
155
148
  };
156
149
 
157
- function getRpcUrlFromChain(chain: Chain): string {
150
+ export function getRpcUrlFromChain(chain: Chain): string {
158
151
  //Prefer user rpc url from env
159
152
  switch (chain.id) {
160
153
  case arbitrum.id:
@@ -213,9 +206,8 @@ function getRpcUrlFromChain(chain: Chain): string {
213
206
  throw new Error(`No RPC URL found for chain ${chain.name}`);
214
207
  }
215
208
 
216
- function getAliasFromNetworkName(networkName: string): string {
209
+ export function getBlockExplorerUrlFromChain(chain: Chain): string | undefined {
217
210
  return (
218
- Object.entries(ALIASES).find(([, alias]) => alias === networkName)?.[0] ||
219
- networkName
211
+ chain.blockExplorers?.default?.url || chain.blockExplorers?.etherscan?.url
220
212
  );
221
213
  }
@@ -1,4 +1,4 @@
1
- import { Address } from "viem";
1
+ import { Address, Chain } from "viem";
2
2
 
3
3
  interface BaseCommandOptions {
4
4
  _: (string | number)[];
@@ -14,11 +14,11 @@ export interface DeployOptions {
14
14
  contract?: string;
15
15
  name?: string;
16
16
  constructorArgs?: NonNullable<unknown>[];
17
+ isOrbit?: boolean;
17
18
  network?: string;
18
19
  estimateGas?: boolean;
19
20
  maxFee?: string;
20
21
  verify?: boolean;
21
- isOrbit?: boolean;
22
22
  }
23
23
 
24
24
  export interface DeploymentData {
@@ -32,7 +32,7 @@ export interface DeploymentConfig {
32
32
  contractFolder: string;
33
33
  contractName: string;
34
34
  deploymentDir: string;
35
- chain?: SupportedNetworkMinimal;
35
+ chain: Chain;
36
36
  }
37
37
 
38
38
  export interface ExportConfig {
@@ -43,10 +43,3 @@ export interface ExportConfig {
43
43
  txHash: string;
44
44
  chainId: string;
45
45
  }
46
-
47
- export interface SupportedNetworkMinimal {
48
- name: string;
49
- alias: string;
50
- id: string;
51
- rpcUrl: string;
52
- }
@@ -233,9 +233,10 @@ Check full documentation for more [details](https://docs.arbitrum.io/stylus/how-
233
233
 
234
234
  ### Stylus Local Verification (Under Development)
235
235
 
236
- Make sure your constructor does not contain any args
236
+ Make sure your contract does not include constructor or constructor does not contain any args
237
237
 
238
238
  ```rs
239
+ [#constructor]
239
240
  pub fn constructor(&mut self)
240
241
  ```
241
242
 
@@ -277,6 +278,23 @@ Check official document for detail instructions: <https://docs.arbitrum.io/stylu
277
278
 
278
279
  > **Note**: Arbiscan verification for Stylus contracts is still evolving. If you encounter issues, consider using the local verification method or check Arbiscan's latest documentation for Stylus-specific instructions.
279
280
 
281
+ **Tip**: If you still want to initialize your contract, then add your own `initialize()` function and initialize it yourself
282
+ Sample :
283
+
284
+ ```
285
+ pub fn initialize(&mut self, initial_number: U256) {
286
+ if !self.is_initialized.get() {
287
+ self.number.set(initial_number);
288
+ self.is_initialized.set(true);
289
+ } else {
290
+ panic!("Counter already initialized");
291
+ }
292
+ }
293
+ ```
294
+
295
+ Then use `cast --rpc-url <your-rpc-url> --private-key <your-private-key> [deployed-contract-address] "initialize(uint256)" <initial_number>`
296
+ Or check [`deploy_contract.ts` lines 95-118](packages/stylus/scripts/deploy_contract.ts#L95-L118) and add it to your `deploy.ts` script.
297
+
280
298
  </details>
281
299
 
282
300
  ## 🛠️ Troubleshooting Common Issues