Substrate .NET Wallet functions for substrate-based nodes
// Create a new Keyring, by default ss58 format is 42 (Substrate standard address)varkeyring=newSubstrate.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 accountvarnewMnemonic=Mnemonic.GenerateMnemonic(MnemonicSize.Words12);// Also available for 15, 18, 21, 24 mnemonic words// Use an existing mnemonicvarexistingMnemonicAccount="entire material egg meadow latin bargain dutch coral blood melt acoustic thought";// Import an account from mnemonic automatically unlock all featurevarfirstWallet=keyring.AddFromMnemonic(existingMnemonicAccount,newMeta(){name="My account name"},NetApi.Model.Types.KeyType.Ed25519);// Account is unlock and ready to sign transaction// Choose a password to protect your account filevarwalletFile=firstWallet.ToWalletFile("MyWallet","myPassword")varjson=firstWallet.ToJson("MyWallet","myPassword");// Now savevarsecondWallet=keyring.AddFromJson(json);// Wallet is imported but locked// You need to unlock the account with the associated passwordsecondWallet.Unlock("myPassword");stringmessage="Hello !";varsignature=firstWallet.Sign(message);varisVerify=firstWallet.Verify(signature,message);