diff --git a/docs/for-devs/oracles/dia/dia.mdx b/docs/for-devs/oracles/dia/dia.mdx deleted file mode 100644 index 7366ea1761..0000000000 --- a/docs/for-devs/oracles/dia/dia.mdx +++ /dev/null @@ -1,67 +0,0 @@ ---- -id: 'dia' -title: 'DIA' -description: Learn how to integrate oracles into your Arbitrum app -user_story: As a developer, I want to understand how to use oracles in Arbitrum to get offchain data onchain. -content_type: how-to ---- - -[DIA](https://www.diadata.org/) is a cross-chain oracle provider that enhances data transparency, customization, and accessibility. With a novel architecture aggregating raw trade data directly from first-party sources, namely centralized and decentralized exchanges, DIA offers 100% source transparency, bespoke customization, and chain-native asset price feeds. - -You can find an example on how to use DIA in your project on this [page](https://docs.diadata.org/introduction/intro-to-dia-oracles/request-an-oracle). - -### How to use DIA oracles on Arbitrum - -**Requesting a custom oracle**: DIA deploys oracles tailored to each app’s needs. Each oracle is customizable, including data sources, cleansing filters, pricing, computational methodologies, update mechanisms, and more. This flexibility ensures that the data and oracle remain robust and resilient to the market conditions and provide a global market price and specific individual or cross-chain market prices. -→ [Request a Custom Oracle for your dApp | DIA Documentation](https://docs.diadata.org/introduction/intro-to-dia-oracles/request-an-oracle) - -### Token Price Feeds - -DIA token price feeds provide smart contracts with real-time price information for [3,000+ cryptocurrencies](https://diadata.org/app/price), sourced from [80+ trusted, high-volume DEXs and CEXs](https://diadata.org/app/source/defi). - -### How to access DIA oracles? - -Here is an example of how to access a price value on DIA oracles: - -1. Access your custom oracle smart contract on Arbitrum. -2. Call `getValue(pair_name)` with `pair_name` being the full pair name such as `BTC/USD`. You can use the "Read" section on the explorer to execute this call. -3. The response of the call contains two values: - -- The current asset price in `USD` with a fix-comma notation of 8 decimals. -- The UNIX timestamp of the last oracle update. - -You can find DIA's oracle integration samples in Solidity and Vyper languages by visiting: -→ [Access the Oracle | DIA Documentation](https://docs.diadata.org/products/token-price-feeds/access-the-oracle) - -### Arbitrum demo price oracles - -DIA has deployed the following demo oracles for the Arbitrum community. It provides a limited selection of cryptocurrency price feeds with predefined configuration settings. - -:::note - -DIA demo oracles are not intended for use in production environments. Developers can request a dedicated, production-ready oracle with custom price feeds and configuration settings. Start the request process: [Request a Custom Oracle | DIA Documentation](https://docs.diadata.org/introduction/intro-to-dia-oracles/request-an-oracle) - -::: - -### Demo Oracle Smart Contracts - -| Network | Contract address | -| ------------- | --------------------------------------------------------------------------------------------------------------------------- | -| Arbitrum | [`0xd041478644048d9281f88558e6088e9da97df624`](https://arbiscan.io/address/0xd041478644048d9281f88558e6088e9da97df624) | -| Arbitrum Nova | [`0xa707a5c6a180da0ae2ef17ebff54f1f3589d9670`](https://nova.arbiscan.io/address/0xa707a5c6a180da0ae2ef17ebff54f1f3589d9670) | - -### Included Price Feeds - -[DIA/USD](https://diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/), [BTC/USD](https://diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/), [USDC/USD](https://diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) - -### Supported token API endpoints - -DIA supports API and GraphQL endpoints to return cryptocurrency price data. You can [visit the DIA Documentation](https://docs.diadata.org/products/token-price-feeds/access-api-endpoints) to see all API endpoints. - -### NFT Price Feeds - -DIA NFT floor price feeds provide smart contracts with real-time price information of [18,000+ NFT collections](https://diadata.org/app/floor-price), sourced onchain with 100% transparency from [multiple, cross-chain NFT marketplaces](https://diadata.org/app/source/nft). - -### Supported NFT API endpoints - -DIA supports API endpoints to return cryptocurrency price data. Developers can directly access the example endpoints listed below or [visit the DIA Documentation](https://docs.diadata.org/use-nexus-product/readme/token-price-feeds/access-api-endpoints) to see all API endpoints. diff --git a/docs/for-devs/oracles/pyth/pyth.mdx b/docs/for-devs/oracles/pyth/pyth.mdx deleted file mode 100644 index 0b63b878b6..0000000000 --- a/docs/for-devs/oracles/pyth/pyth.mdx +++ /dev/null @@ -1,77 +0,0 @@ ---- -id: 'pyth' -title: 'Pyth' -description: 'Learn how to use Pyth Oracle' -author: pete-vielhaber -sme: pete-vielhaber -sidebar_label: 'pyth' -content_type: how-to ---- - -The [Pyth network](https://pyth.network/) a first-party oracle network, securely and transparently delivering real-time market data to [multiple chains](https://docs.pyth.network/price-feeds/contract-addresses). - -The network comprises some of the world’s [largest exchanges, market makers, and financial services providers](https://pyth.network/publishers). These publish proprietary data onchain for aggregation and distribution to smart contract applications. - -## Pyth price feeds - -The Pyth network introduces an innovative low-latency [pull oracle design](https://docs.pyth.network/price-feeds/pull-updates), where users can pull price updates onchain when needed, enabling everyone in the blockchain environment to access that data point. Pyth network updates the prices every 400ms, making Pyth the fastest onchain oracle. - -Here is a working example of a contract that fetches the latest price of `ARB/USD` on the Arbitrum network. - -You have to pass Pyth's contract address for Arbitrum mainnet/testnet and the desired price feed ID to fetch the latest price. - -Install the Pyth SDK Solidity package in your project: - -```tsx -npm install @pythnetwork/pyth-sdk-solidity -``` - -And then, in a few lines of code you can fetch the latest price on the Arbitrum network. - -```solidity -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; -import "@pythnetwork/pyth-sdk-solidity/IPyth.sol"; -import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol"; -contract MyFirstPythContract { - IPyth pyth; - // Pass the address of Pyth's contract for Arbitrum mainnet(0xff1a0f4744e8582DF1aE09D5611b887B6a12925C) - constructor(address _pyth) { - pyth = IPyth(_pyth); - } - function fetchPrice( - bytes[] calldata updateData, - bytes32 priceFeed - ) public payable returns (int64) { - // Fetch the priceUpdate from hermes. - uint updateFee = pyth.getUpdateFee(updateData); - pyth.updatePriceFeeds{value: updateFee}(updateData); - // Fetch the latest price - PythStructs.Price memory price = pyth.getPrice(priceFeed); - return price.price; - } -} -``` - -Here you can fetch the `updateData` from Pyth's [Hermes](https://hermes.pyth.network/docs/) feed, which listens to Pythnet and Wormhole for price updates; or you can use the [pyth-evm-js](https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/sdk/js/src/EvmPriceServiceConnection.ts#L15) SDK. Check [How to Fetch Price Updates](https://docs.pyth.network/price-feeds/fetch-price-updates) to pull the latest data. - -## Pyth Entropy - -Pyth Entropy allows developers to quickly and easily generate secure **random numbers** on the blockchain. - -Check [how to generate random numbers in EVM contracts](https://docs.pyth.network/entropy/generate-random-numbers/evm) for a detailed walkthrough. - -### Supported networks for Arbitrum(Pyth Entropy): - -- Arbitrum: [`0x7698E925FfC29655576D0b361D75Af579e20AdAc`](https://arbiscan.io/address/0x7698E925FfC29655576D0b361D75Af579e20AdAc) -- Arbitrum Sepolia: [`0x549Ebba8036Ab746611B4fFA1423eb0A4Df61440`](https://sepolia.arbiscan.io/address/0x549Ebba8036Ab746611B4fFA1423eb0A4Df61440) - -## Additional resources - -Check out the following links to get started with Pyth: - -- [Pyth EVM Integration Guide](https://docs.pyth.network/price-feeds/use-real-time-data/evm) -- [Pyth Docs](https://docs.pyth.network/home) -- [Pyth API Reference](https://api-reference.pyth.network/price-feeds/evm/getPrice) -- [Pyth Examples](https://github.com/pyth-network/pyth-examples) -- [Pyth Price Feed Ids](https://pyth.network/developers/price-feed-ids) diff --git a/docs/for-devs/oracles/quex/quex.mdx b/docs/for-devs/oracles/quex/quex.mdx deleted file mode 100644 index 7b85efa0dd..0000000000 --- a/docs/for-devs/oracles/quex/quex.mdx +++ /dev/null @@ -1,97 +0,0 @@ ---- -id: 'quex' -title: 'Quex' -sidebar_label: 'Quex' -description: 'Learn how to make verifiable HTTP requests from your Arbitrum dApp' -author: catena2w -sme: catena2w -user_story: As an Arbitrum developer, I want to learn how to use oracles in my dApp. -content_type: get-started ---- - -:::warning - -Quex contracts are currently undergoing security audits and infrastructure security improvements. Before using Quex oracles in production dApps, please reach out via [on Discord](https://discord.com/invite/NsuE32xHvj). Quex will be happy to assist you with the integration and, if needed, set up a dedicated data oracle pools if there is a need. - -::: - -[Quex](https://quex.tech/) is an oracle protocol designed to securely deliver verifiable offchain data to onchain smart contracts using confidential computing proofs. Quex oracles enable dApps on Arbitrum to reliably and securely access real-world data, empowering developers to build advanced financial applications, parametric tokens, prediction markets, and more. - -Unlike traditional oracles, Quex allows developers to securely make verifiable API calls to virtually any offchain data source —– including private APIs protected by credentials. This means you're not limited to predefined data feeds and can securely access the entire internet. - -### Querying the API endpoint through Quex - -Here's an example of how to use Quex to securely fetch the TVL data for the AAVE protocol from DefiLlama's [API endpoint](https://api.llama.fi/tvl/aave). This example will also include basic post-processing to showcase Quex's capabilities for verifiable offchain computations. We'll build our example using [Foundry](https://book.getfoundry.sh) (Forge), but feel free to use your preferred tools. - -Quex provides a package with convenient libraries that simplify making requests and verifying responses. First, install this package in your project: - -```bash -forge install quex-tech/quex-v1-interfaces -``` - -Here's a complete Solidity example demonstrating how to use Quex for verifiable API calls within an Arbitrum smart contract: - -```solidity -import "quex-v1-interfaces/src/libraries/QuexRequestManager.sol"; - -contract ApiCallConsumer is QuexRequestManager { - /** - * Network: Arbitrum One - * Quex Core: 0xD8a37e96117816D43949e72B90F73061A868b387 - * Request Oracle Pool: 0x957E16D5bfa78799d79b86bBb84b3Ca34D986439 - */ - constructor(address _coreAddress, address _poolAddress) QuexRequestManager(_coreAddress){ - setUpFlow(quexCore, oraclePool); - } - - /** - * @notice Creates a new flow to fetch TVL data from the DeFi Llama API for Aave, multiplies it by 1e18, - * and rounds to the nearest integer. - */ - function setUpFlow(address quexCore, address oraclePool) private onlyOwner { - FlowBuilder.FlowConfig memory config = FlowBuilder.create(quexCore, oraclePool, "api.llama.fi", "/tvl/aave"); - config = config.withFilter(". * 1000000000000000000 | round"); - config = config.withSchema("uint256"); - config = config.withCallback(address(this), this.processResponse.selector); - registerFlow(config); - } - - /** - * Verify proofs and processes a response from Request Oracle Pool - */ - function processResponse(uint256 receivedRequestId, DataItem memory response, IdType idType) - external verifyResponse(receivedRequestId, idType) - { - uint256 lastTVL = abi.decode(response.value, (uint256)); - } -} -``` - -The most interesting part here is the `setUpFlow` function. It relies on two contracts, Core and the HTTP oracle pool, that are already [deployed on Arbitrum](https://docs.quex.tech/general-information/addresses). This function specifies the host (`api.llama.fi`) and path (`/tvl/aave`) for future requests that the oracle will perform upon request. - -Most APIs return JSON responses, which aren't very convenient to process directly in Solidity. To extract necessary data, Quex oracles support response post-processing: a script written in the [JQ language](https://docs.quex.tech/developers/https_pool/jq_subset) which is applied before passing the data onchain. Our example script defined in `config.withFilter(". * 1000000000000000000 | round");` multiplies the response by `1e18` and rounds it to the nearest integer. Since Quex supports operations with complex response structures, we must define a schema for the returned result. In our example, `config.withSchema("uint256");` specifies the return type as a simple numeric value. - -As we've mentioned, Quex is a pull oracle operating in a request-response model. Thanks to the efficient confidential computing security model, proof generation is extremely fast, and you can expect responses with proofs delivered in the next block. However, because this is still an asynchronous operation, we must define a callback, a function called once the response is delivered. This is done in the line `config.withCallback(address(this), this.processResponse.selector);`, specifying that the contract's own `processResponse` function will be invoked. - -### Making requests - -Quex supports both offchain and onchain initiated data [delivery modes](https://docs.quex.tech/general-information/data_delivery). This example relies on the on-chain mechanism, meaning that data requests must be initiated directly from your smart contract. To request data, simply call the built-in `request()` method, which triggers the entire process. Note that this method is payable, as you need to attach enough funds to cover the callback gas fees. - -Once the response is generated, it is passed to the `processResponse` method we've specified as a callback. The response arrives with confidential computing proofs, preventing any data manipulation. However, by the time the data reaches your contract, these proofs are already verified within the Quex core. Still, calling `verifyResponse(receivedRequestId, idType)` remains essential to ensure that the response originates from the correct Quex core address and corresponds exactly to the original request. After that, you only need to unpack the data according to the schema you've defined: - -```solidity -uint256 lastTVL = abi.decode(response.value, (uint256)); -``` - -Tada! You now have your response to the defined API call –– with complete certainty about its authenticity and security! - -## Connect with us! - -Still looking for answers? We got them! Check out all the ways you can reach us: - -- Visit us at [quex.tech](https://quex.tech) -- Read our [Docs](https://docs.quex.tech) -- Explore our [examples repository](https://github.com/quex-tech/quex-v1-examples) -- Chat with us on [Telegram](https://t.me/quex_tech) -- Follow us on [X](https://x.com/quex_tech) -- Join our [Discord](https://discord.com/invite/NsuE32xHvj) diff --git a/docs/for-users/contribute.mdx b/docs/for-users/contribute.mdx deleted file mode 100644 index 4f7c3501cf..0000000000 --- a/docs/for-users/contribute.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: 'Contribute docs' -description: "Learn how to contribute to Arbitrum's documentation" ---- - -import ContributeDocsPartial from '../partials/_contribute-docs-partial.mdx'; - - diff --git a/docs/launch-arbitrum-chain/02-configure-your-chain/advanced-configurations/04-deploy-timeboost.mdx b/docs/launch-arbitrum-chain/02-configure-your-chain/advanced-configurations/04-deploy-timeboost.mdx deleted file mode 100644 index d871814667..0000000000 --- a/docs/launch-arbitrum-chain/02-configure-your-chain/advanced-configurations/04-deploy-timeboost.mdx +++ /dev/null @@ -1,195 +0,0 @@ ---- -title: 'Deploy and configure Timeboost for your chain' -sidebar_label: 'Deploy and configure Timeboost' -description: 'Learn how to deploy and configure Timeboost' -user_story: As a current or prospective Orbit chain owner, I need to understand how to deploy and configure Timeboost -author: Jason Wan -sme: Jason Wan -content_type: how-to ---- - -# Enabling Timeboost for your Arbitrum (Orbit) chain - -This guide walks you through the process of enabling Timeboost for your Arbitrum Orbit chain. For a conceptual introduction to Timeboost, see the [Timeboost Introduction](/how-arbitrum-works/timeboost/gentle-introduction.mdx). - -## Prerequisites - -Before starting, ensure you have: - -1. An `ERC-20` token address to use as the bid token -2. A Redis server for auctioneer coordination -3. A server to run the auctioneer service -4. A proxy admin contract address - -## Overview - -Enabling Timeboost requires completing these three steps: - -1. Deploy the `ExpressLaneAuction` contract -2. Run Auctioneer Services (bid validator and auction server) -3. Configure your sequencer node to support Timeboost - -## Step 1: Deploy the `ExpressLaneAuction` contract - -First, clone the `orbit-actions` repository: - -```shell -git clone https://github.com/OffchainLabs/orbit-actions.git -cd orbit-actions/scripts/foundry/timeboost -``` - -Create and edit the environment configuration file: - -```shell -cp .env.sample .env -``` - -Configure the following parameters in your `.env` file: - -```shell -## Configuration for DeployExpressLaneAuction.s.sol -PROXY_ADMIN_ADDRESS= # Your proxy admin contract address -AUCTIONEER_ADDRESS= # Address that will send resolve auction requests -BIDDING_TOKEN_ADDRESS= # Your ERC20 bid token address -BENEFICIARY_ADDRESS= # Address to receive bid proceeds -AUCTIONEER_ADMIN_ADDRESS= # Admin address for the auctioneer -MIN_RESERVE_PRICE_SETTER_ADDRESS= # Address allowed to set minimum reserve price -RESERVE_PRICE_SETTER_ADDRESS= # Address allowed to set reserve price -RESERVE_PRICE_SETTER_ADMIN_ADDRESS= # Admin for reserve price setter -BENEFICIARY_SETTER_ADDRESS= # Address allowed to change beneficiary -ROUND_TIMING_SETTER_ADDRESS= # Address allowed to adjust round timing -MASTER_ADMIN_ADDRESS= # Master admin address - -MIN_RESERVE_PRICE=0 # Minimum price for bids (0 recommended for testing) - -# Round timing configuration (in seconds) -ROUND_DURATION_SECONDS=60 # Total duration of each round -AUCTION_CLOSING_SECONDS=15 # Time before round end when new bids are closed -RESERVE_SUBMISSION_SECONDS=15 # Time allocated for reserve price submission -``` - -Deploy the contract: - -```shell -forge script --sender $DEPLOYER --rpc-url $CHILD_CHAIN_RPC --slow ./DeployExpressLaneAuction.s.sol -vvv --verify --broadcast -# Use --account XXX / --private-key XXX / --interactive / --ledger to specify the transaction signer -``` - -Verify successful deployment by checking that the contract returns your configured bid token: - -```shell -cast call --rpc-url= "biddingToken()(address)" -``` - -Example output: - -```shell -0xYourBidTokenAddress -``` - -## Step 2: Run auctioneer services - -There are two distinct services to run: the bid validator and the auction server. The bid validator verifies submitted bids, while the auction server sends the winning bid on-chain. - -### Prerequisites - -The services require the `autonomous-auctioneer` binary, which is included in the Nitro Docker image. Alternatively, you can build it locally by following the [Build Nitro Locally](https://docs.arbitrum.io/run-arbitrum-node/nitro/build-nitro-locally) guide. - -To build only the `autonomous-auctioneer` component during the local build process: - -```shell -make target/bin/autonomous-auctioneer -``` - -### Running bid validator service - -Start the bid validator with: - -```shell -./autonomous-auctioneer \ ---bid-validator.auction-contract-address= \ ---bid-validator.rpc-endpoint= \ ---auctioneer-server.enable=false \ ---bid-validator.redis-url= \ ---http.addr=0.0.0.0 \ ---http.port= -``` - -### Running auction server service - -Start the auction server with: - -```shell -./autonomous-auctioneer \ ---auctioneer-server.auction-contract-address= \ ---auctioneer-server.db-directory= \ ---auctioneer-server.redis-url= \ ---auctioneer-server.use-redis-coordinator=false \ ---auctioneer-server.sequencer-endpoint= \ ---auctioneer-server.wallet.private-key= \ ---bid-validator.enable=false -``` - -## Step 3: Configure your sequencer node for Timeboost - -Update your sequencer node configuration to enable Timeboost functionality. Add the following new config to your sequencer's node configuration file: - -```json -{ - "http": { - "api": [ - // existing APIs - "auctioneer", - "timeboost" - ] - }, - "ws": { - "api": [ - // existing APIs - "auctioneer", - "timeboost" - ] - }, - "execution": { - "sequencer": { - "timeboost": { - "enable": true, - "auction-contract-address": "", - "auctioneer-address": "", - "redis-url": "" - } - } - } -} -``` - -## Verifying your Timeboost setup - -There are multiple ways to confirm that Timeboost is correctly enabled on your chain: - -### Periodic startup logs - -When you start your sequencer with Timeboost enabled, you'll see periodic logs indicating the start of new express lane auction rounds: - -```shell -New express lane auction round -``` - -This log indicates that the Timeboost mechanism is active and running normally. - -### Transaction processing confirmation - -After finishing a bid request, look for messages in your sequencer logs such as: - -```shell -AuctionResolved: New express lane controller assigned round -``` - -This message confirms that your sequencer is processing express queue transactions from the express lane controller, and that Timeboost is functioning correctly. - -### User interaction verification - -Users can interact with Timeboost by submitting bids through the `auctioneer_submitBid` endpoint of your auctioneer service. -For detailed instructions on how users can interact with Timeboost, see [How to Use Timeboost](https://docs.arbitrum.io/how-arbitrum-works/timeboost/how-to-use-timeboost). - -A successful bid submission will trigger the auction resolution process and generate the corresponding logs mentioned above. diff --git a/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/09-sequencer-timing-adjustments.mdx b/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/09-sequencer-timing-adjustments.mdx deleted file mode 100644 index 9d3ce1e017..0000000000 --- a/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/09-sequencer-timing-adjustments.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Sequencer Timing Adjustments' -description: 'Learn how to configure sequencer timing adjustments for your Arbitrum chain' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/10-per-batch-gas-cost.mdx b/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/10-per-batch-gas-cost.mdx deleted file mode 100644 index dfaa300451..0000000000 --- a/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/10-per-batch-gas-cost.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Per batch gas cost' -description: 'Learn how to configure per batch gas cost for your Arbitrum chain' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/11-smart-contract-size-limit.mdx b/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/11-smart-contract-size-limit.mdx deleted file mode 100644 index f6f3c94abe..0000000000 --- a/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/11-smart-contract-size-limit.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Smart contract size limit' -description: 'Learn how to configure smart contract size limits on your Arbitrum chain' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/12-customizing-anytrust.mdx b/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/12-customizing-anytrust.mdx deleted file mode 100644 index 46a0ea59a0..0000000000 --- a/docs/launch-arbitrum-chain/02-configure-your-chain/common-configurations/12-customizing-anytrust.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Customizing AnyTrust' -description: 'Learn how to customize AnyTrust on your Arbitrum chain' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/02-start-your-journey.mdx b/docs/launch-arbitrum-chain/02-start-your-journey.mdx deleted file mode 100644 index 7efc94581b..0000000000 --- a/docs/launch-arbitrum-chain/02-start-your-journey.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: 'Start your journey into Arbitrum chains' -sidebar_label: 'Arbitrum chain: get started' -description: 'Learn how to get started with Arbitrum chains' -sidebar_position: '2' -author: 'anegg0' -sme: 'mahsamoosavi' -editor: 'anegg0' -target_audience: 'Prospective chain owners, and operators' -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/03-arbitrum-license.mdx b/docs/launch-arbitrum-chain/03-arbitrum-license.mdx deleted file mode 100644 index b727357f1a..0000000000 --- a/docs/launch-arbitrum-chain/03-arbitrum-license.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: 'The Arbitrum chain license' -sidebar_label: 'Arbitrum chain license' -description: '' -sidebar_position: 2 -author: -sme: -editor: anegg0 -target_audience: -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/04-maintain-your-chain/01-bridging.mdx b/docs/launch-arbitrum-chain/04-maintain-your-chain/01-bridging.mdx deleted file mode 100644 index 598237adc9..0000000000 --- a/docs/launch-arbitrum-chain/04-maintain-your-chain/01-bridging.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Bridging' -description: 'PLACEHOLDER' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/04-maintain-your-chain/02-monitoring.mdx b/docs/launch-arbitrum-chain/04-maintain-your-chain/02-monitoring.mdx deleted file mode 100644 index 649e63f45f..0000000000 --- a/docs/launch-arbitrum-chain/04-maintain-your-chain/02-monitoring.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Monitoring' -description: 'Learn how to configure your Arbitrum chain with a custom bond and validator configurations' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/04-maintain-your-chain/04-guidance/01-decentralization-security.mdx b/docs/launch-arbitrum-chain/04-maintain-your-chain/04-guidance/01-decentralization-security.mdx deleted file mode 100644 index 272aab0202..0000000000 --- a/docs/launch-arbitrum-chain/04-maintain-your-chain/04-guidance/01-decentralization-security.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Decentralization and Security' -description: 'PLACEHOLDER' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/04-maintain-your-chain/04-guidance/02-guidance-on-altda.mdx b/docs/launch-arbitrum-chain/04-maintain-your-chain/04-guidance/02-guidance-on-altda.mdx deleted file mode 100644 index eca5d9a361..0000000000 --- a/docs/launch-arbitrum-chain/04-maintain-your-chain/04-guidance/02-guidance-on-altda.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Guidance on AltDA' -description: 'PLACEHOLDER' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/06-third-party-integrations/03-integrations.mdx b/docs/launch-arbitrum-chain/06-third-party-integrations/03-integrations.mdx deleted file mode 100644 index 34c95d1a99..0000000000 --- a/docs/launch-arbitrum-chain/06-third-party-integrations/03-integrations.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: 'Integrations' -description: 'PLACEHOLDER' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- - -## Compatible third-party integrations - -## LayerZero OFT - -## xERC-20 Gateway diff --git a/docs/launch-arbitrum-chain/07-arbitrum-node-runners/arbitrum-chain-node-providers.mdx b/docs/launch-arbitrum-chain/07-arbitrum-node-runners/arbitrum-chain-node-providers.mdx deleted file mode 100644 index 142b208a4a..0000000000 --- a/docs/launch-arbitrum-chain/07-arbitrum-node-runners/arbitrum-chain-node-providers.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Arbitrum chain Node Providers' -description: 'PLACEHOLDER' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -robots: noindex ---- diff --git a/docs/launch-arbitrum-chain/08-ecosystem-support/01-arbitrum-chain-portal.mdx b/docs/launch-arbitrum-chain/08-ecosystem-support/01-arbitrum-chain-portal.mdx deleted file mode 100644 index 7c7c6b0fe6..0000000000 --- a/docs/launch-arbitrum-chain/08-ecosystem-support/01-arbitrum-chain-portal.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Arbitrum chains Portal' -description: 'PLACEHOLDER' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/08-ecosystem-support/03-get-listed-arbitrum-chain-platforms.mdx b/docs/launch-arbitrum-chain/08-ecosystem-support/03-get-listed-arbitrum-chain-platforms.mdx deleted file mode 100644 index 416349caf7..0000000000 --- a/docs/launch-arbitrum-chain/08-ecosystem-support/03-get-listed-arbitrum-chain-platforms.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'Get listed on Arbitrum platforms' -description: 'PLACEHOLDER' -author: -sme: -content_type: how-to -tags: ['hide-from-search'] -unlisted: true ---- diff --git a/docs/launch-arbitrum-chain/arbitrum-chain-supported-parent-chains.mdx b/docs/launch-arbitrum-chain/arbitrum-chain-supported-parent-chains.mdx deleted file mode 100644 index 01cd8daf02..0000000000 --- a/docs/launch-arbitrum-chain/arbitrum-chain-supported-parent-chains.mdx +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: 'Supported parent chains' -sidebar_label: 'Supported parent chains' -description: 'List of officially supported parent chains for Arbitrum chains' -sidebar_position: '2' -author: 'mahsamoosavi' -sme: 'mahsamoosavi' -editor: 'anegg0' -target_audience: 'Arbitrum chains owners and operators' ---- - -This page lists the parent chains that are officially supported for Arbitrum chains, including mainnets, testnets, and options for local development. While the Arbitrum chain SDK provides functionality to enable custom parent chains, support is limited to the chains explicitly listed on this page. Developers are welcome to use the Arbitrum chain SDK to configure and deploy custom parent chains; however, such setups, including deploying the required creator and template contracts, are beyond the scope of our official support. - -:::caution Supported Chains Only - -Please note that we cannot guarantee compatibility or offer assistance for custom configurations outside of the supported chains detailed below. - -::: - -#### Supported chains - -
- -- **Ethereum Mainnet** - **Chain ID:** `1` - -- **Arbitrum One** - **Chain ID:** `42161` - -- **Arbitrum Nova** - **Chain ID:** `42170` - -- **Base** - **Chain ID:** `8453` - -- **Sepolia** - **Chain ID:** `11155111` - -- **Arbitrum Sepolia** - **Chain ID:** `421613` - -- **Base Sepolia** - **Chain ID:** `84531` - -- **Nitro Testnode L1** - **Chain ID:** `1337` - -- **Nitro Testnode L2** - **Chain ID:** `412346` - -- **Nitro Testnode L3** - **Chain ID:** `333333` - -
- -### Adding custom parent chains - -Although Arbitrum chains primarily supports a predefined set of chains, it provides developers with the flexibility to add custom parent chains through [the `registerCustomParentChain` function of the Arbitrum (Orbit) chain SDK](https://github.com/OffchainLabs/arbitrum-orbit-sdk/blob/729facd4d50156d7a84cf1204552c900eb86655c/src/chains.ts#L102). This capability enables integration with chains beyond the officially supported list, offering opportunities for customization and expanding the Arbtrium ecosystem. - -However, adding a custom chain requires deploying essential contracts, such as the creator contract and template contract, on the target chain. These contracts are fundamental for ensuring the proper functioning of the Arbitrum chain framework on the custom chain. diff --git a/docs/launch-arbitrum-chain/partials/_arbitrum-chain-public-preview-banner-partial.md b/docs/launch-arbitrum-chain/partials/_arbitrum-chain-public-preview-banner-partial.md deleted file mode 100644 index 3b33fd052a..0000000000 --- a/docs/launch-arbitrum-chain/partials/_arbitrum-chain-public-preview-banner-partial.md +++ /dev/null @@ -1,7 +0,0 @@ -:::info PUBLIC PREVIEW, MAINNET READY - -Arbitrum chains are now [Mainnet ready](/launch-arbitrum-chain/concepts/public-preview-expectations.mdx#arbitrum-chains-are-mainnet-ready-but-deploy-to-testnet-first)! Note that Arbitrum is still a **[public preview](/launch-arbitrum-chain/concepts/public-preview-expectations.mdx)** capability - the Arbitrum product and its supporting documentation may change significantly as we capture feedback from readers like you. - -To provide feedback, click the _Request an update_ button at the top of this document, [join the Arbitrum Discord](https://discord.gg/arbitrum), or reach out to our team directly by completing [this form](http://bit.ly/3yy6EUK). - -::: diff --git a/docs/node-running/contribute.mdx b/docs/node-running/contribute.mdx deleted file mode 100644 index 4f7c3501cf..0000000000 --- a/docs/node-running/contribute.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: 'Contribute docs' -description: "Learn how to contribute to Arbitrum's documentation" ---- - -import ContributeDocsPartial from '../partials/_contribute-docs-partial.mdx'; - - diff --git a/docs/node-running/how-tos/data-availability-committee/partials/parameters/_ipfs-parameters.mdx b/docs/node-running/how-tos/data-availability-committee/partials/parameters/_ipfs-parameters.mdx deleted file mode 100644 index 2ff2d05dfe..0000000000 --- a/docs/node-running/how-tos/data-availability-committee/partials/parameters/_ipfs-parameters.mdx +++ /dev/null @@ -1,5 +0,0 @@ -| Parameter | Description | -| --------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| --data-availability.ipfs-storage.enable | Enables storage/retrieval of sequencer batch data from IPFS | -| --data-availability.ipfs-storage.profiles | Comma separated list of IPFS profiles to use | -| --data-availability.ipfs-storage.read-timeout | Timeout for IPFS reads, since by default it will wait forever. Treat timeout as not found (default 1m0s) | diff --git a/docs/node-running/node-running-content-map.mdx b/docs/node-running/node-running-content-map.mdx deleted file mode 100644 index 01e0c38fb9..0000000000 --- a/docs/node-running/node-running-content-map.mdx +++ /dev/null @@ -1,98 +0,0 @@ ---- -id: node-running-content-map -title: Run an Arbitrum node -sidebar_label: Run an Arbitrum node ---- - -import Card from '@site/src/components/Cards/Card'; - -# Run an Arbitrum node - -Learn how to run an Arbitrum node. - -
- - - - - - - - - - - - - -
diff --git a/docs/partials/_macos-verify-tx-issue-banner-partial.mdx b/docs/partials/_macos-verify-tx-issue-banner-partial.mdx deleted file mode 100644 index 11df1da02c..0000000000 --- a/docs/partials/_macos-verify-tx-issue-banner-partial.mdx +++ /dev/null @@ -1,13 +0,0 @@ ---- -partial_type: banner -title: 'MacOS Verification Issue Banner' -description: 'Warning banner for MacOS transaction verification limitations' -author: anegg0 -last_reviewed: 2025-01-15 ---- - -:::caution MacOS Users - -This feature is currently unavailable to MacOS users. We are working on a solution and will update this page when this limitation is resolved. - -::: diff --git a/docs/partials/_under-construction-banner-partial.mdx b/docs/partials/_under-construction-banner-partial.mdx deleted file mode 100644 index 1a30c582f3..0000000000 --- a/docs/partials/_under-construction-banner-partial.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -partial_type: banner -title: 'Under Construction Banner' -description: 'Banner indicating document is under construction' -author: anegg0 -last_reviewed: 2025-01-15 ---- - -:::caution UNDER CONSTRUCTION - -This document is currently under construction. - -If you're waiting for this content to be completed, click the `Request an update` button at the top of this page to let us know. We incorporate these requests into our content prioritization discussions. **Thank you!** - -::: diff --git a/docs/stylus/concepts/public-preview-expectations.md b/docs/stylus/concepts/public-preview-expectations.md deleted file mode 100644 index 89a7854c02..0000000000 --- a/docs/stylus/concepts/public-preview-expectations.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: 'Public preview: What to expect' -description: 'Stylus is currently tagged as a `release-candidate` supported by *public preview* documentation. This concept document explains what this means, and what to expect.' -author: symbolpunk -sidebar_position: 10 ---- - -Stylus is currently tagged as a `release-candidate` supported by _public preview_ documentation. This concept document explains what "public preview" means, what to expect from public preview capabilities, and how to engage with our team as you tinker. - -### How products are developed at Offchain Labs - -Offchain Labs builds products in a way that aligns loosely with the spirit of "building in public". We like to release things **early and often** so that we can capture feedback and iterate in service of your needs, as empirically as possible. - -To do this, some of our product offerings are documented with **public preview** disclaimers that look like this: - -This banner's purpose is to set expectations while inviting readers like you to express your needs so that we can incorporate them into the way that we iterate on product. - -### What to expect when using public preview offerings - -As you tinker and provide feedback, we'll be listening. Sometimes, we'll learn something non-obvious that will result in a significant change. More commonly, you'll experience incremental improvements to the developer experience as the offering grows out of its **public preview** status, towards **stable** status. - -Public preview offerings are evolving rapidly, so don't expect the degree of release notes discipline that you'd expect from a stable offering. Keep your eyes open for notifications regarding patch, minor, and major changes, along with corresponding relnotes that highlight breaking changes and new capabilities. - -### How to provide feedback - -Our product team primarily uses three feedback channels while iterating on public preview capabilities: - -1. **Docs**: Click on the **Request an update** button located in the top-right corner of any document to provide feedback on the docs and/or developer experience. This will lead you to a prefilled Github issue that members of our product team periodically review. -2. **Discord**: [Join the Arbitrum Discord](https://discord.gg/arbitrum) to engage with members of the Arbitrum community and product team. -3. **Google form**: Complete [this form](http://bit.ly/3yy6EUK) to ask for support. - -### What to expect when providing feedback - -Our ability to respond to feedback is determined by our ever-evolving capacity and priorities. We can't guarantee responses to all feedback submissions, but our small-but-mighty team is listening, and we'll try our best to acknowledge and respond to your feedback. No guarantees though! - -:::info -[Our small-but-mighty team is hiring](https://jobs.lever.co/offchainlabs). -::: - -### Thank you! - -Thanks for helping us build things that meet your needs! We're excited to engage with OGs and newcomers alike; please don't hesitate to reach out. diff --git a/docs/stylus/how-tos/using-constructors.mdx b/docs/stylus/how-tos/using-constructors.mdx deleted file mode 100644 index c50a713bd4..0000000000 --- a/docs/stylus/how-tos/using-constructors.mdx +++ /dev/null @@ -1,543 +0,0 @@ ---- -title: 'Using constructors with Stylus' -description: 'A comprehensive guide to implementing and deploying smart contracts with constructors in Stylus' -sidebar_label: 'Using constructors' -author: 'anegg0' -sme: 'anegg0' -user_story: 'As a Rust developer, I want to understand how to implement and use constructors in Stylus smart contracts' -content_type: 'how-to' -sidebar_position: 3 -displayed_sidebar: buildAppsSidebar ---- - -import CustomDetails from '@site/src/components/CustomDetails'; -import { VanillaAdmonition } from '@site/src/components/VanillaAdmonition/'; - -Constructors allow you to initialize your Stylus smart contracts with specific parameters when deploying them. This guide will show you how to implement constructors in Rust, understand their behavior, and deploy contracts using them. - -## What you'll accomplish - -By the end of this guide, you'll be able to: - -- Implement constructor functions in Stylus contracts -- Understand the constructor rules and limitations -- Deploy contracts with constructor parameters -- Test the constructor functionality -- Handle constructor errors and validation - -## Prerequisites - -Before implementing constructors, ensure you have: - - - -Follow the instructions on [Rust Lang's installation page](https://www.rust-lang.org/tools/install) to install a complete Rust toolchain (v1.88 or newer) on your system. After installation, ensure you can access the programs `rustup`, `rustc`, and `cargo` from your preferred terminal application. - - - - - -In your terminal, run: - -```shell -cargo install --force cargo-stylus -``` - -Add WASM ([WebAssembly](https://webassembly.org/)) as a build target for the specific Rust toolchain you are using. The below example sets your default Rust toolchain to 1.88 as well as adding the WASM build target: - -```shell -rustup default 1.88 -rustup target add wasm32-unknown-unknown --toolchain 1.88 -``` - -You can verify that cargo stylus is installed by running `cargo stylus --help` in your terminal, which will return a list of helpful commands. - - - - - -Instructions on how to set up a local Arbitrum test node can be found [in the Nitro-devnode repository](https://github.com/OffchainLabs/nitro-devnode). - - - -## Understanding Stylus constructors - -Stylus constructors provide an atomic way to deploy, activate, and initialize a contract in a single transaction. If your contract lacks a constructor, it may allow access to the contract's storage before the initialization logic runs, leading to unexpected behavior. - - - Stylus uses trait-based composition instead of traditional inheritance. When building contracts - that compose multiple traits, constructors help initialize all components properly. See the - [Constructor with trait-based composition](#constructor-with-trait-based-composition) section for - examples. - - -### Constructor rules and guarantees - -Stylus constructors follow these important rules: - -| Rule | Why it exists | -| ------------------------------------------- | --------------------------------------------------------------------------------------- | -| **Exactly 0 or 1 constructor** per contract | Mimics Solidity behavior and avoids ambiguity | -| **Must be annotated with `#[constructor]`** | Guarantees the deployer calls the correct initialization method | -| **Must take `&mut self`** | Allows writing to contract storage during deployment | -| **Returns `()` or `Result<(), Error>`** | Enables error handling; reverting aborts deployment | -| **Use `tx_origin()` for deployer address** | Factory contracts are used in deployment, so `msg_sender()` returns the factory address | -| **Constructor runs exactly once** | The SDK uses a sentinel system to prevent re-execution | - - - Stylus uses a factory pattern for deployment, which means `msg_sender()` in a constructor returns - the factory contract address, not the deployer. Always use `tx_origin()` to get the actual - deployer address. - - -## Basic constructor implementation - -Here's a simple example of a constructor in a Stylus contract: - -```rust -#![cfg_attr(not(any(test, feature = "export-abi")), no_main)] - -extern crate alloc; - -use alloy_primitives::{Address, U256}; -use alloy_sol_types::sol; -use stylus_sdk::prelude::*; - -sol! { - #[derive(Debug)] - error InvalidAmount(); -} - -sol_storage! { - #[entrypoint] - pub struct SimpleToken { - address owner; - uint256 total_supply; - string name; - string symbol; - mapping(address => uint256) balances; - } -} - -#[derive(SolidityError, Debug)] -pub enum SimpleTokenError { - InvalidAmount(InvalidAmount), -} - -#[public] -impl SimpleToken { - /// Constructor initializes the token with a name, symbol, and initial supply - #[constructor] - #[payable] - pub fn constructor( - &mut self, - name: String, - symbol: String, - initial_supply: U256, - ) -> Result<(), SimpleTokenError> { - // Validate input parameters - if initial_supply == U256::ZERO { - return Err(SimpleTokenError::InvalidAmount(InvalidAmount {})); - } - - // Get the deployer address using tx_origin() - let deployer = self.vm().tx_origin(); - - // Initialize contract state - self.owner.set(deployer); - self.name.set_str(&name); - self.symbol.set_str(&symbol); - self.total_supply.set(initial_supply); - - // Mint initial supply to deployer - self.balances.setter(deployer).set(initial_supply); - - Ok(()) - } - - // Additional contract methods... - pub fn balance_of(&self, account: Address) -> U256 { - self.balances.get(account) - } - - pub fn total_supply(&self) -> U256 { - self.total_supply.get() - } -} -``` - -### Key implementation details - -1. **Parameter validation**: Always validate constructor parameters before proceeding with initialization -2. **Error handling**: Use `Result<(), Error>` to handle initialization failures gracefully -3. **Payable constructors**: Add `#[payable]` to receive ETH during deployment -4. **State initialization**: Set all necessary contract state in the constructor - -## Advanced constructor patterns - -### Constructor with complex validation - -```rust -#[constructor] -#[payable] -pub fn constructor( - &mut self, - name: String, - symbol: String, - initial_supply: U256, - max_supply: U256, -) -> Result<(), TokenContractError> { - // Multiple validation checks - if initial_supply == U256::ZERO { - return Err(TokenContractError::InvalidAmount(InvalidAmount {})); - } - - if initial_supply > max_supply { - return Err(TokenContractError::TooManyTokens(TooManyTokens {})); - } - - if name.is_empty() || symbol.is_empty() { - return Err(TokenContractError::InvalidAmount(InvalidAmount {})); - } - - let deployer = self.vm().tx_origin(); - - // Initialize with timestamp tracking - self.owner.set(deployer); - self.name.set_str(&name); - self.symbol.set_str(&symbol); - self.total_supply.set(initial_supply); - self.max_supply.set(max_supply); - self.created_at.set(U256::from(self.vm().block_timestamp())); - - // Mint tokens to deployer - self.balances.setter(deployer).set(initial_supply); - - // Emit initialization event - log(self.vm(), TokenCreated { - creator: deployer, - name: name.clone(), - symbol: symbol.clone(), - initial_supply, - }); - - Ok(()) -} -``` - -### Constructor with trait-based composition - -Stylus uses trait-based composition instead of traditional inheritance. When implementing constructors with traits, each component typically has its own initialization logic: - -```rust -// Define traits for different functionality -trait IErc20 { - fn balance_of(&self, account: Address) -> U256; - fn transfer(&mut self, to: Address, value: U256) -> bool; -} - -trait IOwnable { - fn owner(&self) -> Address; - fn transfer_ownership(&mut self, new_owner: Address) -> bool; -} - -// Define storage for each component -#[storage] -struct Erc20Component { - balances: StorageMap, - total_supply: StorageU256, -} - -#[storage] -struct OwnableComponent { - owner: StorageAddress, -} - -// Main contract that composes functionality -#[storage] -#[entrypoint] -struct MyToken { - erc20: Erc20Component, - ownable: OwnableComponent, - name: StorageString, - symbol: StorageString, -} - -#[public] -#[implements(IErc20, IOwnable)] -impl MyToken { - #[constructor] - pub fn constructor( - &mut self, - name: String, - symbol: String, - initial_supply: U256, - ) -> Result<(), TokenError> { - // Initialize each component - self.initialize_ownable()?; - self.initialize_erc20(initial_supply)?; - - // Initialize contract-specific state - self.name.set_str(&name); - self.symbol.set_str(&symbol); - - Ok(()) - } - - fn initialize_ownable(&mut self) -> Result<(), TokenError> { - let deployer = self.vm().tx_origin(); - self.ownable.owner.set(deployer); - Ok(()) - } - - fn initialize_erc20(&mut self, initial_supply: U256) -> Result<(), TokenError> { - if initial_supply == U256::ZERO { - return Err(TokenError::InvalidSupply); - } - - let deployer = self.vm().tx_origin(); - self.erc20.total_supply.set(initial_supply); - self.erc20.balances.setter(deployer).set(initial_supply); - Ok(()) - } -} -``` - - - Unlike Solidity's inheritance, Stylus uses Rust's trait system for composition. Each component is - initialized explicitly in the constructor. - - -## Testing constructors - -The Stylus SDK provides comprehensive testing tools for constructor functionality: - -```rust -#[cfg(test)] -mod tests { - use super::*; - use stylus_sdk::testing::*; - - #[test] - fn test_constructor_success() { - let vm = TestVMBuilder::new() - .sender(Address::from([0x01; 20])) - .build(); - - let mut contract = SimpleToken::from(&vm); - - let result = contract.constructor( - "Test Token".to_string(), - "TEST".to_string(), - U256::from(1000000), - ); - - assert!(result.is_ok()); - assert_eq!(contract.name.get_string(), "Test Token"); - assert_eq!(contract.symbol.get_string(), "TEST"); - assert_eq!(contract.total_supply.get(), U256::from(1000000)); - assert_eq!( - contract.balance_of(Address::from([0x01; 20])), - U256::from(1000000) - ); - } - - #[test] - fn test_constructor_validation() { - let vm = TestVMBuilder::new() - .sender(Address::from([0x01; 20])) - .build(); - - let mut contract = SimpleToken::from(&vm); - - // Test zero supply rejection - let result = contract.constructor( - "Test Token".to_string(), - "TEST".to_string(), - U256::ZERO, - ); - - assert!(result.is_err()); - assert!(matches!( - result.unwrap_err(), - SimpleTokenError::InvalidAmount(_) - )); - } -} -``` - -## Deploying contracts with constructors - -### Using cargo stylus - -Deploy your contract with constructor arguments using `cargo stylus deploy`: - -```bash -# Deploy with constructor parameters -cargo stylus deploy \ - --private-key-path ~/.arbitrum/key \ - --endpoint https://sepolia-rollup.arbitrum.io/rpc \ - --constructor-args "MyToken" "MTK" 1000000 -``` - -### Constructor argument encoding - -`cargo stylus` automatically encodes the constructor arguments. The arguments should be provided in the same order as defined in your constructor function. - -For complex types: - -- **Strings**: Provide as quoted strings -- **Numbers**: Provide as decimal or hex (0x prefix) -- **Addresses**: Provide as hex strings with 0x prefix -- **Arrays**: Use JSON array syntax - -```bash -# Example with multiple argument types -cargo stylus deploy \ - --constructor-args "TokenName" "TKN" 1000000 "0x742d35Cc6635C0532925a3b8D95B5C1b0ea3C28F" -``` - -## Best practices - -### Constructor parameter validation - -Always validate constructor parameters to prevent deployment of misconfigured contracts: - -```rust -#[constructor] -pub fn constructor(&mut self, params: ConstructorParams) -> Result<(), Error> { - // Validate all parameters before any state changes - self.validate_parameters(¶ms)?; - - // Initialize state only after validation passes - self.initialize_state(params)?; - - Ok(()) -} - -fn validate_parameters(&self, params: &ConstructorParams) -> Result<(), Error> { - if params.name.is_empty() { - return Err(Error::InvalidName); - } - // Additional validation... - Ok(()) -} -``` - -### Error handling patterns - -Use descriptive error types and provide meaningful error messages: - -```rust -sol! { - #[derive(Debug)] - error InvalidName(string reason); - #[derive(Debug)] - error InvalidSupply(uint256 provided, uint256 max_allowed); - #[derive(Debug)] - error Unauthorized(address caller); -} - -#[derive(SolidityError, Debug)] -pub enum ConstructorError { - InvalidName(InvalidName), - InvalidSupply(InvalidSupply), - Unauthorized(Unauthorized), -} -``` - -### State initialization order - -Initialize contract state in a logical order to avoid dependency issues: - -```rust -#[constructor] -pub fn constructor(&mut self, params: ConstructorParams) -> Result<(), Error> { - // 1. Validate parameters first - self.validate_parameters(¶ms)?; - - // 2. Set basic contract metadata - self.name.set_str(¶ms.name); - self.symbol.set_str(¶ms.symbol); - - // 3. Set ownership and permissions - let deployer = self.vm().tx_origin(); - self.owner.set(deployer); - - // 4. Initialize token economics - self.total_supply.set(params.initial_supply); - self.max_supply.set(params.max_supply); - - // 5. Set up initial balances - self.balances.setter(deployer).set(params.initial_supply); - - // 6. Emit events last - log(self.vm(), ContractInitialized { /* ... */ }); - - Ok(()) -} -``` - -## Common pitfalls and solutions - -### Using msg_sender() instead of tx_origin() - -**Problem**: Using `msg_sender()` in constructors returns the factory contract address, not the deployer. - -```rust -// ❌ Wrong - returns factory address -let deployer = self.vm().msg_sender(); - -// ✅ Correct - returns actual deployer -let deployer = self.vm().tx_origin(); -``` - -### Missing parameter validation - -**Problem**: Not validating constructor parameters can lead to unusable contracts. - -```rust -// ❌ Wrong - no validation -#[constructor] -pub fn constructor(&mut self, supply: U256) { - self.total_supply.set(supply); // Could be zero! -} - -// ✅ Correct - validate first -#[constructor] -pub fn constructor(&mut self, supply: U256) -> Result<(), Error> { - if supply == U256::ZERO { - return Err(Error::InvalidSupply); - } - self.total_supply.set(supply); - Ok(()) -} -``` - -### Forgetting the #[constructor] annotation - -**Problem**: Functions named "constructor" without the annotation won't be recognized. - -```rust -// ❌ Wrong - missing annotation -pub fn constructor(&mut self, value: U256) { - // This won't be called during deployment -} - -// ✅ Correct - properly annotated -#[constructor] -pub fn constructor(&mut self, value: U256) { - // This will be called during deployment -} -``` - -## Summary - -Constructors in Stylus provide a powerful way to initialize your smart contracts during deployment. Key takeaways: - -- Use `#[constructor]` annotation and `&mut self` parameter -- Always use `tx_origin()` to get the deployer address -- Validate all parameters before initializing state -- Handle errors gracefully with `Result<(), Error>` return type -- Test the constructor behavior thoroughly -- Deploy with `cargo stylus deploy --constructor-args` diff --git a/docs/stylus/partials/_stylus-public-preview-banner-partial.md b/docs/stylus/partials/_stylus-public-preview-banner-partial.md deleted file mode 100644 index 729f55610d..0000000000 --- a/docs/stylus/partials/_stylus-public-preview-banner-partial.md +++ /dev/null @@ -1,7 +0,0 @@ -:::info ALPHA RELEASE, PUBLIC PREVIEW DOCS - -Stylus is currently tagged as a `release-candidate`. The code has been audited, and testing in production environments is underway. Caution should be taken when used in production scenarios. This documentation is currently in [public preview](/stylus/concepts/public-preview-expectations). - -To provide feedback, click the **Request an update** button at the top of this document, [join the Arbitrum Discord](https://discord.gg/arbitrum), or reach out to our team directly by completing [this form](http://bit.ly/3yy6EUK). - -::: diff --git a/src/components/FloatingHoverModal/index.js b/src/components/FloatingHoverModal/index.js index 71b07d2871..12a385372b 100644 --- a/src/components/FloatingHoverModal/index.js +++ b/src/components/FloatingHoverModal/index.js @@ -32,7 +32,6 @@ import ConfigPermissionedValidators from '@site/docs/launch-arbitrum-chain/parti import ConfigL1ChallengePeriod from '@site/docs/launch-arbitrum-chain/partials/config-l1-challenge-period.mdx'; import ConfigForceInclusion from '@site/docs/launch-arbitrum-chain/partials/config-force-inclusion.mdx'; import ConfigAccountAbstraction from '@site/docs/launch-arbitrum-chain/partials/config-account-abstraction.mdx'; -import ConfigChallengePeriod from '@site/docs/launch-arbitrum-chain/partials/config-challenge-period-l1.mdx'; import ConfigCustomizableGovernance from '@site/docs/launch-arbitrum-chain/partials/config-customizable-governance.mdx'; import ConfigDataPostingCosts from '@site/docs/launch-arbitrum-chain/partials/config-data-posting-costs.mdx'; import ConfigEVMCompatibility from '@site/docs/launch-arbitrum-chain/partials/config-evm-compatbility.mdx'; @@ -54,7 +53,6 @@ const contentMap = { 'config-l1-challenge-period': ConfigL1ChallengePeriod, 'config-force-inclusion': ConfigForceInclusion, 'config-account-abstraction': ConfigAccountAbstraction, - 'config-challenge-period-l1': ConfigChallengePeriod, 'config-customizable-governance': ConfigCustomizableGovernance, 'config-data-posting-costs': ConfigDataPostingCosts, 'config-evm-compatibility': ConfigEVMCompatibility,