Substrate .NET Wallet functions for substrate-based nodes
// Create a new Keyring, by default ss58 format is 42 (Substrate standard address)
var keyring = new Substrate.NET.Wallet.Keyring.Keyring();
// You can specify ss58 address if needed (check SS58 regitry here : https://github.com/paritytech/ss58-registry/blob/main/ss58-registry.json)
keyring.Ss58Format = 0; // Polkadot
// Generate a new mnemonic for a new account
var newMnemonic = Mnemonic.GenerateMnemonic(MnemonicSize.Words12);
// Also available for 15, 18, 21, 24 mnemonic words
// Use an existing mnemonic
var existingMnemonicAccount = "entire material egg meadow latin bargain dutch coral blood melt acoustic thought";
// Import an account from mnemonic automatically unlock all feature
var firstWallet = keyring.AddFromMnemonic(existingMnemonicAccount, new Meta() { name = "My account name"}, NetApi.Model.Types.KeyType.Ed25519);
// Account is unlock and ready to sign transaction
// Choose a password to protect your account file
var walletFile = firstWallet.ToWalletFile("MyWallet", "myPassword")
var json = firstWallet.ToJson("MyWallet", "myPassword");
// Now save
var secondWallet = keyring.AddFromJson(json);
// Wallet is imported but locked
// You need to unlock the account with the associated password
secondWallet.Unlock("myPassword");
string message = "Hello !";
var signature = firstWallet.Sign(message);
var isVerify = firstWallet.Verify(signature, message);