Skip to main content

Network Configuration

Configure your application for different MultiversX networks.

Available Networks​

NetworkChain IDPurpose
Mainnet1Production
DevnetDDevelopment & Testing
TestnetTTesting

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​

NetworkURL
Mainnethttps://gateway.multiversx.com
Devnethttps://devnet-gateway.multiversx.com
Testnethttps://testnet-gateway.multiversx.com

API URLs​

NetworkURL
Mainnethttps://api.multiversx.com
Devnethttps://devnet-api.multiversx.com
Testnethttps://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​

FieldTypeDescription
chainIdStringNetwork identifier (1, D, T)
minGasPriceintMinimum gas price per gas unit
minGasLimitintMinimum gas limit for a transaction with no data
gasPerDataByteintGas cost per byte of the data field
minTransactionVersionintLowest transaction version the chain accepts
maxGasPerTransactionintPer-transaction gas ceiling
extraGasLimitGuardedTxintExtra gas charged for a guarded transaction
extraGasLimitRelayedTxintExtra gas charged for a relayed transaction
gasPriceModifierdoubleFraction of the gas price refunded on unused gas
numShardsintNumber of shards in the network
roundDurationintDuration of a round in milliseconds
roundsPerEpochintRounds in each epoch
denominationintToken denomination (18 for EGLD)
topUpFactordoubleTop-up factor for staking rewards
adaptivityboolWhether adaptive sharding is enabled
hysteresisStringHysteresis value for shard rebalancing
latestTagSoftwareVersionString?Node software version tag
numNodesInShardint?Nodes per shard
numMetachainNodesint?Nodes on the metachain
shardConsensusGroupSizeint?Consensus group size in a shard
metaConsensusGroupSizeint?Consensus group size on the metachain
rewardsTopUpGradientPointString?Top-up gradient point for rewards
startTimeint?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:

FieldDefaultApplies to
minGasLimit50000Floor for every transaction
gasLimitPerByte1500Each byte of the data field
gasLimitEsdtTransfer200000ESDTTransfer
gasLimitEsdtNftTransfer200000ESDTNFTTransfer
gasLimitMultiEsdtNftTransfer200000MultiESDTNFTTransfer
gasLimitIssue60000000Token issuance
gasLimitSetSpecialRole60000000Role management
gasLimitStake5000000Validator staking
gasLimitCreateDelegationContract50000000Delegation contract creation
extraGasLimitForGuardedTransactions50000Guarded transactions
extraGasLimitForRelayedTransactions50000Relayed 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​