### Install Foundry Development Tools
Source: https://context7_llms
Installs the Foundry development toolkit, which includes forge, cast, and anvil. Foundry is a portable Ethereum development toolkit necessary for deploying and interacting with smart contracts.
```shell
curl -L https://foundry.paradigm.xyz | bash
foundryup
```
--------------------------------
### Install Foundry Development Tools using foundryup
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
This snippet demonstrates how to download and install the Foundry development toolkit, which includes forge, cast, anvil, and chisel. Foundry is a portable Ethereum development toolkit essential for smart contract development and testing.
```bash
# Download foundry installer
foundryup
```
```bash
# Install forge, cast, anvil, chisel
foundryup
```
--------------------------------
### Solidity Test Contract for HelloArchitect
Source: https://context7_llms
This Solidity code defines test cases for the 'HelloArchitect' contract using the Foundry testing framework. It includes setup, initial greeting verification, setting a new greeting, and verifying event emissions. Dependencies include 'forge-std/Test.sol' and the contract under test, '../src/HelloArchitect.sol'.
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
import "forge-std/Test.sol";
import "../src/HelloArchitect.sol";
contract HelloArchitectTest is Test {
HelloArchitect helloArchitect;
function setUp() public {
helloArchitect = new HelloArchitect();
}
function testInitialGreeting() public view {
string memory expected = "Hello Architect!";
string memory actual = helloArchitect.getGreeting();
assertEq(actual, expected);
}
function testSetGreeting() public {
string memory newGreeting = "Welcome to Arc Chain!";
helloArchitect.setGreeting(newGreeting);
string memory actual = helloArchitect.getGreeting();
assertEq(actual, newGreeting);
}
function testGreetingChangedEvent() public {
string memory newGreeting = "Building on Arc!";
// Expect the GreetingChanged event to be emitted
vm.expectEmit(true, true, true, true);
emit HelloArchitect.GreetingChanged(newGreeting);
helloArchitect.setGreeting(newGreeting);
}
}
```
--------------------------------
### Implement HelloArchitect Solidity Smart Contract
Source: https://context7_llms
Defines a simple storage contract named 'HelloArchitect' using Solidity. The contract manages a greeting message, allowing it to be set and retrieved, and emits an event when the greeting changes. Requires Solidity compiler version 0.8.30 or higher.
```solidity
// SPDX-License-Identifier: MIT\npragma solidity ^0.8.30;\n\ncontract HelloArchitect {\n string private greeting;\n\n // Event emitted when the greeting is changed\n event GreetingChanged(string newGreeting);\n\n // Constructor that sets the initial greeting to "Hello Architect!"\n constructor() {\n greeting = "Hello Architect!";\n }\n\n // Setter function to update the greeting\n function setGreeting(string memory newGreeting) public {\n greeting = newGreeting;\n emit GreetingChanged(newGreeting);\n }\n\n // Getter function to return the current greeting\n function getGreeting() public view returns (string memory) {\n return greeting;\n }\n}
```
--------------------------------
### Initialize a new Solidity Project with Forge
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Initializes a new Solidity project using the Forge build system, a part of the Foundry toolkit. This command creates a standard project structure for developing smart contracts.
```bash
forge init hello-arc && cd hello-arc
```
--------------------------------
### Call Contract Function with cast
Source: https://context7_llms
Demonstrates how to call the `getGreeting` function on the HelloArchitect contract using the `cast call` command. Requires the contract address and RPC URL to be set as environment variables.
```shell
cast call $HELLOARCHITECT_ADDRESS "getGreeting()(string)" \
--rpc-url $ARC_TESTNET_RPC_URL
```
--------------------------------
### Write the HelloArchitect Solidity Contract
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Defines the 'HelloArchitect' smart contract in Solidity. This contract stores a greeting message, allows it to be updated, and emits an event when the greeting changes. It includes a constructor, a setter function, and a getter function.
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
contract HelloArchitect {
string private greeting;
// Event emitted when the greeting is changed
event GreetingChanged(string newGreeting);
// Constructor that sets the initial greeting to "Hello Architect!"
constructor() {
greeting = "Hello Architect!";
}
// Setter function to update the greeting
function setGreeting(string memory newGreeting) public {
greeting = newGreeting;
emit GreetingChanged(newGreeting);
}
// Getter function to return the current greeting
function getGreeting() public view returns (string memory) {
return greeting;
}
}
```
--------------------------------
### Deploy HelloArchitect Contract to Arc Testnet
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Deploys the 'HelloArchitect' smart contract to the Arc Testnet using Foundry. It requires the RPC URL for the testnet and the deployer's private key, typically loaded from environment variables.
```bash
forge create src/HelloArchitect.sol:HelloArchitect \
--rpc-url $ARC_TESTNET_RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast
```
--------------------------------
### Test HelloArchitect Contract with Foundry
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Defines test cases for the 'HelloArchitect' smart contract using Foundry's testing framework. It includes tests for the initial greeting, setting a new greeting, and verifying the 'GreetingChanged' event emission. Requires 'forge-std/Test.sol' and the 'HelloArchitect.sol' contract.
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
import "forge-std/Test.sol";
import "../src/HelloArchitect.sol";
contract HelloArchitectTest is Test {
HelloArchitect helloArchitect;
function setUp() public {
helloArchitect = new HelloArchitect();
}
function testInitialGreeting() public view {
string memory expected = "Hello Architect!";
string memory actual = helloArchitect.getGreeting();
assertEq(actual, expected);
}
function testSetGreeting() public {
string memory newGreeting = "Welcome to Arc Chain!";
helloArchitect.setGreeting(newGreeting);
string memory actual = helloArchitect.getGreeting();
assertEq(actual, newGreeting);
}
function testGreetingChangedEvent() public {
string memory newGreeting = "Building on Arc!";
// Expect the GreetingChanged event to be emitted
vm.expectEmit(true, true, true, true);
emit HelloArchitect.GreetingChanged(newGreeting);
helloArchitect.setGreeting(newGreeting);
}
}
```
--------------------------------
### Arc EVM Compatibility
Source: https://context7_llms
Overview of Arc's EVM compatibility, highlighting key differences from Ethereum such as USDC as gas and deterministic finality.
```APIDOC
## Arc EVM Compatibility
### Description
Arc is compatible with the Ethereum Virtual Machine (EVM), allowing developers to use familiar tools, languages, and frameworks like Solidity, Foundry, and Hardhat. While the execution environment is similar to Ethereum, Arc introduces specific differences to enhance predictability and stability.
### Key Differences from Ethereum:
* **USDC as Native Gas**: All transaction fees and balances are denominated in USDC, not ETH.
* **Deterministic Finality**: Transactions are finalized instantly and cannot be reversed, ensuring immediate certainty.
* **Simplified Block Times**: Blocks are timestamped based on real time, simplifying scheduling and synchronization.
* **Stable Fee Model**: Gas prices are smoothed to provide predictable transaction costs.
* **Permissioned Validators**: Arc utilizes a BFT consensus model (Malachite) for high speed and reliability.
### ERC20 Interface for USDC
Arc uses USDC as its native network token, with native balances represented by 18 decimals. An optional ERC20 interface is also available, which uses **6 decimals** to match the standard USDC representation on other EVM networks.
**Implications of the ERC20 Interface:**
1. **Tiny USDC Amounts**: Transfers of very small USDC amounts (less than 1 x 10⁻⁶ USDC) are not possible using the ERC20 interface.
2. **Automatic Native Balance Reflection**: Protocols holding USDC as an ERC20 automatically possess equivalent native balances. No Solidity code changes are needed (e.g., for `payable` or `receive` functions) as ERC20 transfers are directly reflected in the native balance.
```
--------------------------------
### Generate New Wallet with Cast
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Creates a new cryptographic keypair (address and private key) using the Cast command-line tool. The output includes the generated address and private key, which should be securely stored.
```bash
cast wallet new
```
--------------------------------
### Compile Smart Contract with Foundry
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Compiles the smart contracts within the project and generates necessary build artifacts, including bytecode and ABI. This typically creates an 'out' directory containing these artifacts.
```bash
forge build
```
--------------------------------
### Call getGreeting Function with cast
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
This command uses `cast call` to interact with a deployed contract. It specifically calls the `getGreeting` function, which returns a string, from the `HelloArchitect` contract. Ensure that `$HELLOARCHITECT_ADDRESS` and `$ARC_TESTNET_RPC_URL` are set as environment variables.
```bash
cast call $HELLOARCHITECT_ADDRESS "getGreeting()(string)" \
--rpc-url $ARC_TESTNET_RPC_URL
```
--------------------------------
### Run Foundry Contract Tests
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Executes all unit tests defined for the project using the Foundry test runner. This command compiles the project, runs the tests, and displays the results in the terminal.
```bash
forge test
```
--------------------------------
### Store Private Key in .env File
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Stores the generated private key in a '.env' file for use in subsequent commands. This is a common practice for managing sensitive information locally.
```dotenv
PRIVATE_KEY="0x..."
```
--------------------------------
### Arc Network System Architecture Diagram
Source: https://context7_llms
A Mermaid diagram illustrating the high-level system architecture of the Arc Network, showing the interaction between the Consensus layer (Malachite) and the Execution layer (Reth) with its sub-components.
```mermaid
%%{init: {"flowchart": {"curve": "basis"}} }%%
flowchart TB
subgraph Consensus["Consensus layer (Malachite)"]
C["Consensus Process
(Ordering & Finality)"]
end
subgraph Execution["Execution layer (Reth)"]
L["Ledger & State"]
F["Fee Manager"]
P["Privacy Module"]
S["Stablecoin
Services"]
end
C --> L
L --> F
L --> P
L --> S
```
--------------------------------
### StableFX Escrow Contract
Source: https://context7_llms
Information about the StableFX escrow contract used for settling stablecoin swaps on Arc.
```APIDOC
## StableFX Escrow Contract
### Description
This section details the FxEscrow contract address used by StableFX for settling stablecoin swaps on the Arc network. It is essential for both makers and takers participating in these swaps.
### Contract
FxEscrow
### Address
`0x1f91886C7028986aD885ffCee0e40b75C9cd5aC1`
### Notes
The escrow contract used by both makers and takers to settle stablecoin swaps.
### Prerequisites
Before executing FX trades with StableFX, users must grant a USDC allowance to the Permit2 contract. Refer to the 'Common Ethereum contracts' section for the Permit2 address.
```
--------------------------------
### Configure Arc Testnet RPC URL in .env File
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Sets the environment variable for the Arc Testnet RPC URL within a .env file. This allows Foundry to connect to the Arc Testnet for deployment and interaction. Sensitive information like RPC URLs should not be committed to version control.
```dotenv
ARC_TESTNET_RPC_URL="https://rpc.testnet.arc.network"
```
--------------------------------
### Store Deployed Contract Address in .env
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Saves the address of the deployed 'HelloArchitect' contract to the '.env' file. This address is necessary for interacting with the deployed contract in future operations.
```dotenv
HELLOARCHITECT_ADDRESS="0x..."
```
--------------------------------
### Reload Environment Variables
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Reloads the environment variables from the '.env' file into the current shell session. This makes variables like PRIVATE_KEY accessible to subsequent commands.
```bash
source .env
```
--------------------------------
### Common Ethereum Contracts on Arc Testnet
Source: https://context7_llms
Details on common Ethereum ecosystem contracts deployed on Arc Testnet for compatibility and enhanced functionality.
```APIDOC
## Common Ethereum Contracts on Arc Testnet
### Description
Arc Testnet includes a set of widely used Ethereum ecosystem contracts that facilitate deterministic deployment, batched reads, and standardized token approvals. These contracts are deployed on Arc to ensure compatibility with common EVM tooling and workflows.
### Contracts
#### CREATE2 Factory (Arachnid)
- **Address**: `0x4e59b44847b379578588920cA78FbF26c0B4956C`
- **Notes**: Minimal proxy for deterministic contract deployment using the `CREATE2` opcode.
#### Multicall3
- **Address**: `0xcA11bde05977b3631167028862bE2a173976CA11`
- **Notes**: Aggregates multiple read calls into a single call for efficient data retrieval.
#### Permit2
- **Address**: `0x000000000022D473030F116dDEE9F6B43aC78BA3`
- **Notes**: Universal contract for signature-based token approvals. Required for StableFX.
```
--------------------------------
### Delete Script Directory
Source: https://docs.arc.network/arc/tutorials/deploy-on-arc
Removes the 'script' directory to avoid compilation errors caused by references to deleted contracts like 'Counter.sol'. This action is a preparatory step before adding new deployment scripts.
```bash
rm -rf script
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.