Substrate.fromSeed constructor
Substrate.fromSeed(
- List<
int> seedBytes, - SubstrateCoins coinType
Create a Substrate context from a seed and coin type.
Implementation
factory Substrate.fromSeed(List<int> seedBytes, SubstrateCoins coinType) {
if (seedBytes.length < SubstrateConst.seedMinByteLen) {
throw ArgumentException(
'Seed length is too small, it shall be at least ${SubstrateConst.seedMinByteLen} bytes',
);
}
final seed = seedBytes.sublist(0, SubstrateConst.seedMinByteLen);
final SchnorrkelMiniSecretKey miniSecretKey =
SchnorrkelMiniSecretKey.fromBytes(seed);
final secretKey = miniSecretKey.toSecretKey();
return Substrate._(
SubstratePrivateKey.fromBytes(
secretKey.toBytes(), SubstrateConf.getCoin(coinType)),
SubstratePublicKey.fromBytes(
secretKey.publicKey().toBytes(), SubstrateConf.getCoin(coinType)),
SubstratePath(),
SubstrateConf.getCoin(coinType),
);
}