Network Configuration
Configure your application for different MultiversX networks.
Available Networks
| Network | Chain ID | Purpose |
|---|---|---|
| Mainnet | 1 | Production |
| Devnet | D | Development & Testing |
| Testnet | T | Testing |
Quick Configuration
// Devnet for development
final devnet = GatewayNetworkProvider.devnet();
// Mainnet for production
final mainnet = GatewayNetworkProvider.mainnet();
// Testnet
final testnet = GatewayNetworkProvider.testnet();
Network URLs
Gateway URLs
| Network | URL |
|---|---|
| Mainnet | https://gateway.multiversx.com |
| Devnet | https://devnet-gateway.multiversx.com |
| Testnet | https://testnet-gateway.multiversx.com |
API URLs
| Network | URL |
|---|---|
| Mainnet | https://api.multiversx.com |
| Devnet | https://devnet-api.multiversx.com |
| Testnet | https://testnet-api.multiversx.com |
Network Configuration Object
Get dynamic network configuration:
final provider = GatewayNetworkProvider.devnet();
final config = await provider.getNetworkConfig();
print('Chain ID: ${config.chainId}');
print('Min gas price: ${config.minGasPrice}');
print('Min gas limit: ${config.minGasLimit}');
print('Gas per data byte: ${config.gasPerDataByte}');
print('Denomination: ${config.denomination}');
print('Rounds per epoch: ${config.roundsPerEpoch}');
NetworkConfig Fields
| Field | Type | Description |
|---|---|---|
chainId | String | Network identifier (1, D, T) |
minGasPrice | int | Minimum gas price per gas unit |
minGasLimit | int | Minimum gas limit for a transaction with no data |
gasPerDataByte | int | Gas cost per byte of the data field |
minTransactionVersion | int | Lowest transaction version the chain accepts |
maxGasPerTransaction | int | Per-transaction gas ceiling |
extraGasLimitGuardedTx | int | Extra gas charged for a guarded transaction |
extraGasLimitRelayedTx | int | Extra gas charged for a relayed transaction |
gasPriceModifier | double | Fraction of the gas price refunded on unused gas |
numShards | int | Number of shards in the network |
roundDuration | int | Duration of a round in milliseconds |
roundsPerEpoch | int | Rounds in each epoch |
denomination | int | Token denomination (18 for EGLD) |
topUpFactor | double | Top-up factor for staking rewards |
adaptivity | bool | Whether adaptive sharding is enabled |
hysteresis | String | Hysteresis value for shard rebalancing |
latestTagSoftwareVersion | String? | Node software version tag |
numNodesInShard | int? | Nodes per shard |
numMetachainNodes | int? | Nodes on the metachain |
shardConsensusGroupSize | int? | Consensus group size in a shard |
metaConsensusGroupSize | int? | Consensus group size on the metachain |
rewardsTopUpGradientPoint | String? | Top-up gradient point for rewards |
startTime | int? | Genesis timestamp in seconds |
gasPriceModifier is a double (0.01 by default), so it can be applied to a
gas price directly:
final config = await provider.getNetworkConfig();
final refundedPerUnit = config.minGasPrice * config.gasPriceModifier;
Environment-Based Configuration
enum Environment { development, staging, production }
class AppConfig {
final Environment environment;
AppConfig(this.environment);
GatewayNetworkProvider get provider {
switch (environment) {
case Environment.development:
return GatewayNetworkProvider.devnet();
case Environment.staging:
return GatewayNetworkProvider.testnet();
case Environment.production:
return GatewayNetworkProvider.mainnet();
}
}
String get explorerUrl {
switch (environment) {
case Environment.development:
return 'https://devnet-explorer.multiversx.com';
case Environment.staging:
return 'https://testnet-explorer.multiversx.com';
case Environment.production:
return 'https://explorer.multiversx.com';
}
}
}
// Usage
final config = AppConfig(Environment.development);
final provider = config.provider;
Configuration from Environment Variables
import 'dart:io';
GatewayNetworkProvider createProvider() {
final network = Platform.environment['MVX_NETWORK'] ?? 'devnet';
switch (network.toLowerCase()) {
case 'mainnet':
return GatewayNetworkProvider.mainnet();
case 'testnet':
return GatewayNetworkProvider.testnet();
case 'devnet':
default:
return GatewayNetworkProvider.devnet();
}
}
Gas Configuration
Factory Gas Schedule
Transaction factories do not guess gas: they read it from
TransactionsFactoryConfig, which carries the chain's gas schedule and is
shared by every factory built from the same config (or the same
entrypoint).
const config = TransactionsFactoryConfig(chainId: ChainId.devnet());
print(config.minGasLimit); // 50000
print(config.gasLimitPerByte); // 1500
print(config.gasLimitEsdtTransfer); // 200000
print(config.gasLimitIssue); // 60000000
Selected defaults:
| Field | Default | Applies to |
|---|---|---|
minGasLimit | 50000 | Floor for every transaction |
gasLimitPerByte | 1500 | Each byte of the data field |
gasLimitEsdtTransfer | 200000 | ESDTTransfer |
gasLimitEsdtNftTransfer | 200000 | ESDTNFTTransfer |
gasLimitMultiEsdtNftTransfer | 200000 | MultiESDTNFTTransfer |
gasLimitIssue | 60000000 | Token issuance |
gasLimitSetSpecialRole | 60000000 | Role management |
gasLimitStake | 5000000 | Validator staking |
gasLimitCreateDelegationContract | 50000000 | Delegation contract creation |
extraGasLimitForGuardedTransactions | 50000 | Guarded transactions |
extraGasLimitForRelayedTransactions | 50000 | Relayed transactions |
How a factory computes a gas limit
Every factory-built transaction pays for the bytes it moves on top of the endpoint's execution cost:
gasLimit = minGasLimit
+ gasLimitPerByte * data.length
+ <execution gas for the endpoint>
So an ESDTTransfer whose data field is 60 bytes costs
50000 + 1500 * 60 + 200000. Override the whole calculation by passing an
explicit gasLimit to the factory method.
Reading the live schedule
The values above are the SDK's defaults. To read what the network currently enforces, ask the provider:
final networkConfig = await provider.getNetworkConfig();
print(networkConfig.minGasLimit);
print(networkConfig.gasPerDataByte);
print(networkConfig.maxGasPerTransaction);
Token Identifiers by Network
Wrapped EGLD and common tokens differ per network:
class Tokens {
static const mainnet = _MainnetTokens();
static const devnet = _DevnetTokens();
static TokenConfig forNetwork(String chainId) {
switch (chainId) {
case '1':
return mainnet;
case 'D':
return devnet;
default:
throw ArgumentError('Unknown network: $chainId');
}
}
}
class _MainnetTokens implements TokenConfig {
const _MainnetTokens();
String get wegld => 'WEGLD-bd4d79';
String get usdc => 'USDC-c76f1f';
String get mex => 'MEX-455c57';
}
class _DevnetTokens implements TokenConfig {
const _DevnetTokens();
String get wegld => 'WEGLD-a28c59';
String get usdc => 'USDC-8d4068';
String get mex => 'MEX-dc289c';
}
abstract class TokenConfig {
String get wegld;
String get usdc;
String get mex;
}
Complete Configuration Example
import 'package:abidock_mvx/abidock_mvx.dart';
import 'dart:io';
/// Application configuration
class Config {
final String network;
final GatewayNetworkProvider provider;
final String chainId;
final String explorerUrl;
final TokenConfig tokens;
Config._({
required this.network,
required this.provider,
required this.chainId,
required this.explorerUrl,
required this.tokens,
});
static Future<Config> load() async {
final network = Platform.environment['MVX_NETWORK'] ?? 'devnet';
late GatewayNetworkProvider provider;
late String chainId;
late String explorerUrl;
late TokenConfig tokens;
switch (network.toLowerCase()) {
case 'mainnet':
provider = GatewayNetworkProvider.mainnet();
chainId = '1';
explorerUrl = 'https://explorer.multiversx.com';
tokens = Tokens.mainnet;
break;
case 'testnet':
provider = GatewayNetworkProvider.testnet();
chainId = 'T';
explorerUrl = 'https://testnet-explorer.multiversx.com';
tokens = Tokens.devnet; // Use devnet tokens
break;
case 'devnet':
default:
provider = GatewayNetworkProvider.devnet();
chainId = 'D';
explorerUrl = 'https://devnet-explorer.multiversx.com';
tokens = Tokens.devnet;
}
// Verify connection
final config = await provider.getNetworkConfig();
assert(config.chainId == chainId);
return Config._(
network: network,
provider: provider,
chainId: chainId,
explorerUrl: explorerUrl,
tokens: tokens,
);
}
String txUrl(String hash) => '$explorerUrl/transactions/$hash';
String addressUrl(String address) => '$explorerUrl/accounts/$address';
}
// Usage
void main() async {
final config = await Config.load();
print('Network: ${config.network}');
print('Chain ID: ${config.chainId}');
print('WEGLD: ${config.tokens.wegld}');
}
Next Steps
- Network Providers - Provider setup
- WebSocket Events - Real-time updates
- Transactions - Sending transactions