|
2 | 2 | "thirdweb": minor |
3 | 3 | --- |
4 | 4 |
|
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