-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
215 additions
and
77 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...orbit-chain/how-tos/interactive-how-to/partials/_approve-erc20-token-partial.md
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,32 @@ | ||
## Approve ERC-20 token | ||
|
||
Initiating the deployment of a token bridge for **[Custom Fee Token](/launch-orbit-chain/concepts/custom-gas-token-sdk.md)** on orbit chains begins with ensuring the `TokenBridgeCreator` contract is granted sufficient approvals of the native token. To facilitate this process, the Orbit SDK provides two APIs: | ||
|
||
1. **`createTokenBridgeEnoughCustomFeeTokenAllowance`**: This method verifies that the deployer's address has enough allowance to pay for the fees associated with the token bridge deployment. | ||
2. **`createTokenBridgePrepareCustomFeeTokenApprovalTransactionRequest`**: This function assists in generating the raw transaction required to approve the native token for the `TokenBridgeCreator` contract. | ||
|
||
The following example demonstrates how to leverage these APIs effectively to check for and, if necessary, grant approval to the `TokenBridgeCreator` contract: | ||
|
||
```js | ||
const allowanceParams = { | ||
nativeToken, | ||
owner: rollupOwner.address, | ||
publicClient: parentChainPublicClient, | ||
}; | ||
if (!(await createTokenBridgeEnoughCustomFeeTokenAllowance(allowanceParams))) { | ||
const approvalTxRequest = await createTokenBridgePrepareCustomFeeTokenApprovalTransactionRequest( | ||
allowanceParams, | ||
); | ||
} | ||
``` | ||
|
||
In this scenario, `allowanceParams` includes: | ||
- The native token's details: `nativeToken`. | ||
- The Rollup owner's address: `rollupOwner.address`. | ||
- The parent chain's publicClient: `parentChainPublicClient`. | ||
|
||
First, `createTokenBridgeEnoughCustomFeeTokenAllowance` checks if the deployer has been granted enough allowance. | ||
|
||
If the allowance is insufficient, `createTokenBridgePrepareCustomFeeTokenApprovalTransactionRequest` is called to create the necessary approval transaction. | ||
|
||
Please note that after generating the raw transaction, the deployer must still sign and broadcast it to the network to finalize the approval process. |
16 changes: 16 additions & 0 deletions
16
...hain/how-tos/interactive-how-to/partials/_deploy-orbit-chain-helpers-partial.md
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,16 @@ | ||
n and deployment helpers | ||
|
||
The Orbit SDK provides three APIs, `prepareChainConfig`, `createRollupPrepareConfig`, and `createRollupPrepareTransactionRequest` to facilitate the configuration and deployment of Rollup parameters for an Orbit chain. These APIs simplify the process of setting up and deploying the core contracts necessary for an Orbit chain. | ||
|
||
| API | Benefit | Description | | ||
| :-------------------------------------- | :----------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- | | ||
| `prepareChainConfig` | Simplifies the creation of the `chainConfig` parameter object | Takes `config` parameters as arguments and returns a `chainConfig` `JSON` string. | | ||
| `createRollupPrepareConfig` | Simplifies the creation of the `Config` parameter object | Takes a `Config` struct as argument and fills in undefined params with default values. | | ||
| `createRollupPrepareTransactionRequest` | Simplifies the creation of the `RollupDeploymentParams` parameter object | Takes `RollupDeploymentParams` as argument, applies defaults where necessary, and return a complete `RollupDeploymentParams` | | ||
| `createTokenBridgeEnoughCustomFeeTokenAllowance` | Verifies that the deployer's address has enough allowance to pay for the fees associated with the token bridge deployment | | | ||
| `createTokenBridgePrepareCustomFeeTokenApprovalTransactionRequest` | Generates the raw transaction required to approve the native token for the `TokenBridgeCreator` contract. | | | ||
| `createTokenBridgePrepareTransactionRequest` | Generates token bridge deployment transaction request.| | | ||
| `waitForRetryables` | Sends token bridge deployment transaction.| | | ||
|
||
|
||
|
76 changes: 0 additions & 76 deletions
76
...-orbit-chain/how-tos/interactive-how-to/partials/_deploy-orbit-chain-helpers.md
This file was deleted.
Oops, something went wrong.
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
...t-chain/how-tos/interactive-how-to/partials/_get-deployed-chain-info-partial.md
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,15 @@ | ||
## Get the orbit chain information after deployment | ||
|
||
Once you've successfully deployed your Orbit chain, the next step is to retrieve detailed information about the deployment. The Orbit SDK provides a convenient way to do this through the `createRollupPrepareTransactionReceipt` API. | ||
|
||
After sending the signed transaction and receiving the transaction receipt, you can use the `createRollupPrepareTransactionReceipt` API to parse this receipt and extract the relevant data. This process will provide comprehensive details about the deployed chain, such as contract addresses, configuration settings, and other information. | ||
|
||
Here's an example of how to use the Orbit SDK to get data from a deployed Orbit chain: | ||
|
||
```js | ||
import { createRollupPrepareTransactionReceipt } from '@arbitrum/orbit-sdk'; | ||
|
||
const data = createRollupPrepareTransactionReceipt(txReceipt); | ||
``` | ||
|
||
In this example, `txReceipt` refers to the transaction receipt you received after deploying the chain. By passing this receipt to the `createRollupPrepareTransactionReceipt` function, you can easily access a wealth of information about your Orbit chain. This feature of the Orbit SDK simplifies the post-deployment process, allowing you to quickly and efficiently gather all necessary details about your chain for further use or reference. |
34 changes: 34 additions & 0 deletions
34
...eractive-how-to/partials/_prepare-chainConfig-parameter-for-AnyTrust-partial.md
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,34 @@ | ||
## Prepare `ChainConfig` object parameter | ||
|
||
For an easier config preparation, the Orbit SDK provides the `prepareChainConfig` API, which takes config parameters as arguments and returns a `chainConfig` `JSON` string. Any parameters not provided will default to standard values, which are detailed in the [Orbit SDK repository](https://github.com/OffchainLabs/arbitrum-orbit-sdk/blob/1f251f76a55bc1081f50938b0aa9f7965660ebf7/src/prepareChainConfig.ts#L3-L31). | ||
|
||
|
||
The `chainConfig` parameter within the `Config` structure is an essential element for tailoring your Orbit chain according to specific needs. This parameter is particularly significant when setting up an AnyTrust Orbit chain, as it includes configurations that distinguish it from a Rollup chain. The key parameter that differentiates an AnyTrust chain in this context is the `DataAvailabilityCommittee`. | ||
|
||
|
||
|
||
Here are the parameters you can use with `prepareChainConfig`: | ||
|
||
| Parameter | Description | | ||
| :-------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `chainId` | Your Orbit chain's unique identifier. It differentiates your chain from others in the ecosystem. | | ||
| `DataAvailabilityCommittee` | Set to `false`, this boolean makes your chain as a Rollup, set to `true` configures it as an AnyTrust chain. | | ||
| `InitialChainOwner` | Identifies who owns and controls the chain. | | ||
| `MaxCodeSize ` | Sets the maximum size for contract bytecodes on the Orbit chain. e.g. Ethereum mainnet has a limit of 24,576 Bytes. | | ||
| `MaxInitCodeSize` | Similar to `MaxCodeSize`, defines the maximum size for your Orbit chain's **initialization** code. e.g. Ethereum mainnet limit is 49,152 Bytes. | | ||
|
||
|
||
For an AnyTrust chain, you need to set the `DataAvailabilityCommittee` to **true**. This setting is crucial as it indicates the chain's reliance on a committee for data availability, which is a hallmark of the AnyTrust model. | ||
|
||
Here’s an example of how to configure the `chainConfig` for an AnyTrust chain using the Orbit SDK: | ||
|
||
```js | ||
import { prepareChainConfig } from '@arbitrum/orbit-sdk'; | ||
|
||
const chainConfig = prepareChainConfig({ | ||
chainId: Some_Chain_ID, | ||
arbitrum: { InitialChainOwner: deployer_address, DataAvailabilityCommittee: true }, | ||
}); | ||
``` | ||
|
||
In this example, you set up the chain configuration with a specific `chainId`, the `InitialChainOwner` as the deployer's address, and importantly, you configure the `DataAvailabilityCommittee` as `true`. This configuration ensures that your Orbit chain is set up as an AnyTrust chain, utilizing the unique features and operational model of the AnyTrust system within the Arbitrum Orbit framework. |
24 changes: 24 additions & 0 deletions
24
...nteractive-how-to/partials/_prepare-chainConfig-parameter-for-Rollup-partial.md
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,24 @@ | ||
## Prepare `chainConfig` object parameter | ||
|
||
For an easier config preparation, the Orbit SDK provides the `prepareChainConfig` API, which takes config parameters as arguments and returns a `chainConfig` `JSON` string. Any parameters not provided will default to standard values, which are detailed in the [Orbit SDK repository](https://github.com/OffchainLabs/arbitrum-orbit-sdk/blob/1f251f76a55bc1081f50938b0aa9f7965660ebf7/src/prepareChainConfig.ts#L3-L31). | ||
|
||
Here are the parameters you can use with `prepareChainConfig`: | ||
|
||
| Parameter | Description | | ||
| :-------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `chainId` | Your Orbit chain's unique identifier. It differentiates your chain from others in the ecosystem. | | ||
| `DataAvailabilityCommittee` | Set to `false`, this boolean makes your chain as a Rollup, set to `true` configures it as an AnyTrust chain. | | ||
| `InitialChainOwner` | Identifies who owns and controls the chain. | | ||
| `MaxCodeSize ` | Sets the maximum size for contract bytecodes on the Orbit chain. e.g. Ethereum mainnet has a limit of 24,576 Bytes. | | ||
| `MaxInitCodeSize` | Similar to `MaxCodeSize`, defines the maximum size for your Orbit chain's **initialization** code. e.g. Ethereum mainnet limit is 49,152 Bytes. | | ||
|
||
Below is an example of how to use `prepareChainConfig` to set up a Rollup chain with a specific `chainId`, an `InitialChainOwner` (named as `deployer_address`): | ||
|
||
```js | ||
import { prepareChainConfig } from '@arbitrum/orbit-sdk'; | ||
|
||
const chainConfig = prepareChainConfig({ | ||
chainId: Some_Chain_ID, | ||
arbitrum: { InitialChainOwner: deployer_address, DataAvailabilityCommittee: false }, | ||
}); | ||
``` |
15 changes: 15 additions & 0 deletions
15
...-chain/how-tos/interactive-how-to/partials/_prepare-config-parameter-partial.md
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,15 @@ | ||
#### createRollupPrepareConfig API: | ||
|
||
This API is designed to take parameters defined in the Config struct and fill in the rest with default values. It outputs a complete Config struct that is ready for use. | ||
|
||
For example, to create a Config struct with a specific chain ID (`chainId`), an owner address (`deployer_address`), and a `chainConfig` as described in the [previous section](#chain-config-parameter), you would use the Orbit SDK as follows: | ||
|
||
```js | ||
import { createRollupPrepareConfig } from '@arbitrum/orbit-sdk'; | ||
|
||
const config = createRollupPrepareConfig({ | ||
chainId: BigInt(chainId), | ||
owner: deployer.address, | ||
chainConfig, | ||
}); | ||
``` |
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
Oops, something went wrong.