Network Configuration
This page provides the full network configuration for AgentChain, along with setup instructions for common development tools.
Network Details
| Parameter | Value |
|---|---|
| Network Name | AgentChain |
| Chain ID | 7331 |
| Network ID | 7331 |
| Currency Symbol | CRD |
| Decimals | 18 |
| RPC Endpoint | http://localhost:8545 |
| WebSocket Endpoint | ws://localhost:8546 |
| Consensus | RandomX PoW |
| EVM Version | Berlin |
| Block Time | 6 seconds |
| Gas Limit | 10M – 60M (dynamic) |
| Block Explorer | agentchain.org/explorer |
| Agent API | agent_* namespace (key-free, see docs) |
RPC Endpoint
The default JSON-RPC endpoint is:
http://localhost:8545
This supports all standard Ethereum JSON-RPC methods including eth_call, eth_sendRawTransaction, eth_getBalance, eth_estimateGas, and others. It also supports the agent_* namespace for key-free AI agent operations.
For AI agents: Use the
agent_*namespace instead of managing private keys. See the Agent API Reference.
WebSocket Endpoint
For subscriptions and event streaming, use the WebSocket endpoint:
ws://localhost:8546
WebSocket connections support eth_subscribe for listening to new blocks, pending transactions, and log events in real time.
Adding AgentChain to MetaMask
To add AgentChain to MetaMask manually:
- Open MetaMask and click the network dropdown.
- Select Add network then Add a network manually.
- Fill in the following fields:
| Field | Value |
|---|---|
| Network Name | AgentChain |
| New RPC URL | http://localhost:8545 |
| Chain ID | 7331 |
| Currency Symbol | CRD |
| Block Explorer URL | (leave blank) |
- Click Save.
You should now see AgentChain as a selectable network in MetaMask with CRD as the native currency.
Hardhat Configuration
Add AgentChain as a network in your hardhat.config.js or hardhat.config.ts:
// hardhat.config.js
module.exports = {
solidity: {
version: "0.8.19",
settings: {
evmVersion: "berlin",
},
},
networks: {
agentchain: {
url: process.env.CRD_RPC_URL || "http://localhost:8545",
chainId: 7331,
// accounts: [process.env.CRD_PRIVATE_KEY],
},
},
};Deploy to AgentChain with:
npx hardhat run scripts/deploy.js --network agentchainKey points for Hardhat on AgentChain:
- Set
evmVersionto"berlin"to avoid generating incompatible bytecode. - Use Solidity 0.8.19 or earlier. Later versions default to the Shanghai or Cancun EVM, which includes
PUSH0and other opcodes not supported on AgentChain. - Do not use EIP-1559 gas configuration fields (
maxFeePerGas,maxPriorityFeePerGas). Hardhat will use legacy gas pricing by default when connected to a non-EIP-1559 chain.
Foundry Configuration
Add AgentChain to your foundry.toml:
[profile.default]
solc_version = "0.8.19"
evm_version = "berlin"
[rpc_endpoints]
agentchain = "${CRD_RPC_URL}"Deploy a contract with Foundry:
export CRD_RPC_URL="http://localhost:8545"
forge create src/MyContract.sol:MyContract \
--rpc-url agentchain \
--private-key $CRD_PRIVATE_KEY \
--legacyThe --legacy flag is required to ensure Foundry sends a type-0 (legacy) transaction instead of an EIP-1559 transaction.
Run tests against a Berlin-compatible local environment:
forge test --evm-version berlinPython web3.py Provider Setup
HTTP Provider
from web3 import Web3
rpc_url = "http://localhost:8545" # or use os.environ["CRD_RPC_URL"]
w3 = Web3(Web3.HTTPProvider(rpc_url))
assert w3.is_connected(), "Failed to connect to AgentChain"
assert w3.eth.chain_id == 7331, "Wrong network"WebSocket Provider
from web3 import Web3
ws_url = "ws://localhost:8546"
w3 = Web3(Web3.WebsocketProvider(ws_url))
assert w3.is_connected(), "Failed to connect to AgentChain"Using Middleware
If you are using web3.py v6+, you may want to add the geth_poa_middleware if your node returns extraData fields longer than 32 bytes:
from web3 import Web3
from web3.middleware import ExtraDataToPOAMiddleware
w3 = Web3(Web3.HTTPProvider("http://localhost:8545"))
w3.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0)Environment Variables
AI agents using the
agent_*API do not need private keys. The environment variables below are only needed for standard Ethereum library usage (ethers.js, web3.py).
It is best practice to configure RPC endpoints and private keys through environment variables rather than hardcoding them. The recommended convention for AgentChain:
| Variable | Description | Example |
|---|---|---|
| CRD_RPC_URL | HTTP RPC endpoint | http://localhost:8545 |
| CRD_WS_URL | WebSocket endpoint | ws://localhost:8546 |
| CRD_PRIVATE_KEY | Account private key (hex) | 0xac0974bec... |
| CRD_CHAIN_ID | Chain ID (optional, for validation) | 7331 |
Setting Environment Variables
Linux / macOS:
export CRD_RPC_URL="http://localhost:8545"
export CRD_WS_URL="ws://localhost:8546"
export CRD_PRIVATE_KEY="0xYourPrivateKeyHere"Windows (PowerShell):
$env:CRD_RPC_URL = "http://localhost:8545"
$env:CRD_WS_URL = "ws://localhost:8546"
$env:CRD_PRIVATE_KEY = "0xYourPrivateKeyHere"Using in Python
import os
from web3 import Web3
rpc_url = os.environ.get("CRD_RPC_URL", "http://localhost:8545")
w3 = Web3(Web3.HTTPProvider(rpc_url))Using in JavaScript
import { ethers } from "ethers";
const rpcUrl = process.env.CRD_RPC_URL || "http://localhost:8545";
const provider = new ethers.JsonRpcProvider(rpcUrl);Never commit private keys to version control. Use .env files with a library like python-dotenv or dotenv for Node.js, and make sure .env is listed in your .gitignore.
Next Steps
With your environment configured, you are ready to start building on AgentChain. Explore the rest of the documentation to learn about deploying smart contracts, building agent workflows, and interacting with the network programmatically.