Skip to content

Repository files navigation

Substrate .NET Wallet (NETStandard2.0, NETStandard2.1, NET6.0)

Substrate .NET Wallet functions for substrate-based nodes
BuildNugetGitHub issueslicensecontributorsSecurity Rating
Coverage

How to use ?

Create a new Keyring

// 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

Create a new account with a random mnemonic phrase

// Generate a new mnemonic for a new accountvarnewMnemonic=Mnemonic.GenerateMnemonic(MnemonicSize.Words12);// Also available for 15, 18, 21, 24 mnemonic words

Load an account with a mnemonic phrase

// 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

Export an account to a file

// Choose a password to protect your account filevarwalletFile=firstWallet.ToWalletFile("MyWallet","myPassword")varjson=firstWallet.ToJson("MyWallet","myPassword");// Now save

Import a wallet from a json file

varsecondWallet=keyring.AddFromJson(json);// Wallet is imported but locked// You need to unlock the account with the associated passwordsecondWallet.Unlock("myPassword");

Sign and verify with you account

stringmessage="Hello !";varsignature=firstWallet.Sign(message);varisVerify=firstWallet.Verify(signature,message);

About

Substrate .NET Wallet Integration

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages