generated from ChainSafe/yarn-workspaces-typescript-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* v0 * v0.1 * v1 * v1.1 * v1.1.1 * v1.1.2 * v1.2 * v1.3 * v1.4 * v1.4.1 * v1.5.0 * v1.6.0 * v1.6.1 * v1.6.2
- Loading branch information
Showing
5 changed files
with
223 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# DeployOptions | ||
|
||
DeployOptions provides additional configuration settings for deploying smart contracts across multiple blockchain networks. These options allow for customization of the deployment process, including contract address generation, network-specific deployments, and transaction settings. | ||
|
||
## Interface | ||
|
||
```ts | ||
interface DeployOptions { | ||
salt?: MatchPrimitiveType<"bytes32", unknown>; | ||
isUniquePerChain?: boolean; | ||
customNonPayableTxOptions?: NonPayableCallOptions; | ||
} | ||
``` | ||
|
||
## Usages | ||
|
||
### salt | ||
- **Description**: Provides entropy for generating a unique contract address. This can be a hexadecimal string `HexString` or a `Uint8Array`. | ||
- **Purpose**: Used to create a predictable yet unique address for the smart contract across different deployments. | ||
|
||
### isUniquePerChain | ||
- **Description**: A boolean flag that, when set to true, ensures the contract is deployed with distinct addresses on each blockchain network. | ||
|
||
### customNonPayableTxOptions | ||
- **Details**: Customizes transaction settings for contract calls. This option allows setting sender details and other transaction parameters. | ||
- **Reference**: For detailed information about `NonPayableCallOptions`, please refer to the [web3.js documentation](https://docs.web3js.org/api/web3-types/interface/NonPayableCallOptions/). | ||
|
||
## Example | ||
|
||
In this example, `DeployOptions` is configured to deploy a contract with a specified salt for address generation, ensuring unique addresses on each chain, and customizing the sender address for the deployment transaction. | ||
|
||
```ts | ||
const options: DeployOptions = { | ||
salt: "0x0d832502cc5af3e4cf5c9118b013acea29808616be3bd44f89d231c1c56af61f", | ||
isUniquePerChain: true, | ||
customNonPayableTxOptions: { | ||
from: "0x1605B51d318bFfBFd246D565Ee55522b66ddc34a", | ||
}, | ||
}; | ||
``` | ||
|
||
This setup ensures a predictable and unique deployment process tailored to specific requirements of a multichain environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# NetworkArguments | ||
|
||
NetworkArguments define the configuration for deploying smart contracts across various blockchain networks. This setup allows for specifying different deployment settings for each network, providing detailed control over the deployment process. | ||
|
||
## Interface | ||
|
||
```typescript | ||
interface NetworkArguments<Abi extends ContractAbi = any> { | ||
[network: string]: NetworkArgument<Abi>; | ||
} | ||
|
||
interface NetworkArgument<Abi extends ContractAbi = any> { | ||
args: ContractConstructorArgs<Abi>; | ||
initData?: { | ||
initMethodName: keyof ContractMethods<Abi>; | ||
initMethodArgs: unknown[]; | ||
}; | ||
} | ||
``` | ||
|
||
## Usages | ||
|
||
### NetworkArguments | ||
- **Description**: An object where each key is a network name registered on Sygma, mapped to their respective `NetworkArgument`. This structure facilitates network-specific deployment configurations, allowing for deployment across networks recognized by the Sygma protocol. | ||
- **Purpose**: Enables the deployment of contracts to specified networks, leveraging the configurations tailored for each network as recognized by Sygma. | ||
|
||
### NetworkArgument | ||
- **args** | ||
- **Description**: Constructor arguments for the contract on each specified network. | ||
- **Purpose**: Used for initializing the contract upon deployment. | ||
|
||
- **initData** | ||
- **Description**: An optional object that specifies additional initialization to be performed after the contract's deployment. When used, it must include both `initMethodName` and `initMethodArgs`. | ||
- **initMethodName** | ||
- **Description**: Specifies the contract method to call for further initialization. | ||
- **initMethodArgs** | ||
- **Description**: An array of values that correspond to the parameters required by the method named in `initMethodName`. These arguments are passed directly to the initialization method call. | ||
|
||
## Example | ||
|
||
```typescript | ||
const abi = [ ... ] as const; | ||
|
||
const networks: NetworkArguments<typeof abi> = { | ||
sepolia: { | ||
args: [18, "zToken"], | ||
initData: { | ||
initMethodName: "setName", | ||
initMethodArgs: ["SuperToken"], | ||
} | ||
}, | ||
goerli: { | ||
args: [18, "zToken"], | ||
initData: { | ||
initMethodName: "setName", | ||
initMethodArgs: ["GummyToken"], | ||
} | ||
}, | ||
}; | ||
``` | ||
|
||
This example shows how `NetworkArguments` can be used to deploy a contract with specific constructor arguments on the Sepolia and Goerli test networks. It includes optional post-deployment initialization to set unique token names for each network through the `setName` method. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters