Network class
Represents a Stellar network (public, testnet, or custom).
The Network class specifies which Stellar network to use for transactions. Each network has a unique network passphrase that is hashed into every transaction hash, preventing transactions from one network being replayed on another network (replay attack protection).
Available networks:
- PUBLIC: The production Stellar network (mainnet)
- TESTNET: The test network for development and testing
- FUTURENET: The network for testing upcoming protocol features
Network passphrases are critical for security:
- Transactions signed for one network cannot be submitted to another
- The passphrase is hashed into the transaction signature
- Always verify you're using the correct network before signing
Example usage:
// Sign for testnet (development)
transaction.sign(keyPair, Network.TESTNET);
// Sign for mainnet (production)
transaction.sign(keyPair, Network.PUBLIC);
// Create custom network (for standalone/private networks)
Network customNetwork = Network("Custom Network ; January 2024");
transaction.sign(keyPair, customNetwork);
Security warnings:
- NEVER use TESTNET credentials on PUBLIC network
- NEVER use PUBLIC network for testing
- Always double-check network before signing with real funds
- Test thoroughly on TESTNET before deploying to PUBLIC
See also:
- Transaction.sign for signing with a specific network
- Transaction.hash to compute network-specific transaction hash
- Stellar developer docs
Constructors
- Network(String _networkPassphrase)
- Creates a new Network object to represent a network with a given networkPassphrase.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- networkId → Uint8List?
-
Returns the network id (SHA-256 hashed networkPassphrase).
no setter
- networkPassphrase → String
-
Returns the network passphrase of this network.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited