Skip to content

Commit 3f58afb

Browse files
committed
feat: Add deployment utility functions for infrastructure and contract initialization
1 parent 4de72f0 commit 3f58afb

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

.changeset/long-queens-draw.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,61 @@
22
"thirdweb": minor
33
---
44

5-
empty
5+
Added new deployment utility functions to help manage infrastructure contracts and initialization:
6+
7+
- `getDeployedCloneFactoryContract`: Get the deployed clone factory contract instance
8+
- `getDeployedInfraContract`: Get or deploy infrastructure contracts like WETH, Forwarder etc
9+
- `getAllDefaultConstructorParamsForImplementation`: Get default constructor params for contract implementations
10+
- `getInitializeTransaction`: Prepare initialization transaction for contract deployment
11+
- `getOrDeployInfraForPublishedContract`: Get or deploy required infrastructure for published contracts
12+
13+
```typescript
14+
import {
15+
getDeployedCloneFactoryContract,
16+
getDeployedInfraContract,
17+
getAllDefaultConstructorParamsForImplementation,
18+
getInitializeTransaction,
19+
getOrDeployInfraForPublishedContract
20+
} from "thirdweb";
21+
22+
// Get deployed clone factory
23+
const factory = await getDeployedCloneFactoryContract({
24+
client,
25+
chain
26+
});
27+
28+
// Get or deploy WETH contract
29+
const weth = await getDeployedInfraContract({
30+
client,
31+
chain,
32+
contractId: "WETH9"
33+
});
34+
35+
// Get default constructor params
36+
const params = await getAllDefaultConstructorParamsForImplementation({
37+
chain,
38+
client
39+
});
40+
41+
// Get initialization transaction
42+
const initTx = await getInitializeTransaction({
43+
client,
44+
chain,
45+
account,
46+
implementationContract,
47+
deployMetadata,
48+
initializeParams: {
49+
name: "My Contract",
50+
symbol: "CNTRCT"
51+
}
52+
});
53+
54+
// Get or deploy infrastructure
55+
const infra = await getOrDeployInfraForPublishedContract({
56+
chain,
57+
client,
58+
account,
59+
contractId: "MyContract",
60+
constructorParams: params
61+
});
62+
```

0 commit comments

Comments
 (0)