waves_logo Docs
  • Overview
    Overview
  • How-to Guides
    • Reading Blockchain Data
      Reading Blockchain Data
    • Creating & Broadcasting Transactions
      Creating & Broadcasting Transactions
    • Tokenization
      Tokenization
    • Airdrop
      Airdrop
    • Payments
      Payments
    • Exchange Tokens
      Exchange Tokens
    • Simple Voting
      Simple Voting
    • List as argument
      List as argument
    How-to Guides
  • Waves Smart Contracts
    Waves Smart Contracts
  • dApp
    • Creating & Launching dApp
      Creating & Launching dApp
    dApp
  • Smart Account
    • Creating smart account
      Creating smart account
    • Creating and deploying a script manually
      Creating and deploying a script manually
    • Video tutorials
      • Introduction to the Waves blockchain, Waves Smart Accounts and Waves Smart Assets
        Introduction to the Waves blockchain, Waves Smart Accounts and Waves Smart Assets
      • Waves Smart Account with multisignature
        Waves Smart Account with multisignature
      • Waves Smart Account with escrow service
        Waves Smart Account with escrow service
      • Creating multisignature account via Waves IDE tools
        Creating multisignature account via Waves IDE tools
      • Creating multisignature account via Waves Client
        Creating multisignature account via Waves Client
      • Waves console explained
        Waves console explained
      Video tutorials
    Smart Account
  • Smart Asset
    Smart Asset
  • Developer Tools
    • Waves IDE
      Waves IDE
    • Visual Studio Code Extension
      Visual Studio Code Extension
    • Surfboard
      Surfboard
    • Ride REPL
      Ride REPL
    Developer Tools
  • Signer ◆
    Signer ◆
  • Waves API
    • Data Service API
      Data Service API
    • Node REST API
      Node REST API
    • Node gRPC Server
      Node gRPC Server
    • Blockchain Updates
      Blockchain Updates
    Waves API
  • Client Libraries
    • Waves C#
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      Waves C#
    • Gowaves
      • Install SDK
        Install SDK
      Gowaves
    • WavesJ
      • Install SDK
        Install SDK
      WavesJ
    • Ts-lib-crypto
      • Install SDK
        Install SDK
      Ts-lib-crypto
    • Waves-PHP
      • Install SDK
        Install SDK
      Waves-PHP
    • Waves-python
      • Install SDK
        Install SDK
      Waves-python
    • Waves-rust
      • Install SDK
        Install SDK
      Waves-rust
    Client Libraries
      • English
      • Русский
      On this page
        • Private Key
        • Public Key
        • Address
      waves_logo Docs

          # Use Crypto Utilities

          Before working with the Private Key, Public Key, or Address, include the following initialization snippet at the beginning of each script:

          // Required imports.
          using WavesLabs.Node.Transactions.Common;
          using WavesLabs.Node.Transactions.Utils;
          using WavesLabs.Node.Transactions;
          using WavesLabs.Node.Client;
          

          # Private Key

          You can create a private key from:

          • Seed phrase.
          • Randomly generated seed phrase.
          • Randomly generated seed phrase with nonce 2.
          • Seed bytes.
          • Randomly generated seed bytes.
          • Bytes.
          • Encoded string.

          # Create Private Key from Seed

          // Create a private key from a seed phrase.
          var senderPrivateKey = PrivateKey.FromSeed("PASTE_YOUR_SEED_PHRASE_HERE");
          

          # Generate Random Seed Phrase and Private Key

          // Generate a random seed phrase.
          var seed = Crypto.GenerateRandomSeedPhrase();
          
          // Create the private key from the generated seed phrase.
          var senderPrivateKey = PrivateKey.FromSeed(seed);
          

          # Generate Random Seed Phrase with Nonce 2

          // Generate a random seed phrase.
          var seed = Crypto.GenerateRandomSeedPhrase();
          
          // Create the private key from the generated seed phrase with a nonce of 2.
          var senderPrivateKey = PrivateKey.FromSeed(seed, 2);
          

          # Create a Private Key from Seed Bytes

          // Create a seed phrase represented as bytes.
          byte[] seedBytes = { 21, 55, 87, 117, 8, 81, 77, 77, 99, 87, 23, 7, 116, 99, 20, 12, 4 };
          
          // Generate the private key from the seed phrase bytes.
          var senderPrivateKey = PrivateKey.FromSeed(seedBytes);
          

          # Create a Private Key from Randomly Generated Seed Bytes

          // Generate a random seed phrase as bytes.
          byte[] randomSeedBytes = Crypto.GenerateRandomSeedBytes();
          
          // Create the private key from the generated seed phrase bytes.
          var senderPrivateKey = PrivateKey.FromSeed(randomSeedBytes);
          

          # Create a Private Key from Bytes

          // Define a byte array.
          byte[] bytes = { 56, 3, 37, 64, 2, 38, 78, 37, 98, 45, 23, 117, 14, 88, 20, 42, 9, 21, 55, 87, 117, 8, 81, 77, 77, 99, 87, 23, 7, 116, 99, 20 };
          
          // Create the private key from the byte array.
          var senderPrivateKey = PrivateKey.As(bytes);
          

          # Create a Private Key from an Encoded String

          // Define a Base58 encoded string.
          var base58PhraseEncoded = "PASTE_YOUR_BASE58_ENCODED_STRING_HERE";
          
          // Create the private key from the Base58 encoded string.
          var senderPrivateKey = PrivateKey.As(base58PhraseEncoded);
          

          # Public Key

          You can create a public key from a private key:

          // Specify the sender private key.
          var senderPrivateKey = "PASTE_THE_SENDER_PRIVATE_KEY_HERE";
          
          // Derive the public key from the private key.
          var senderPublicKey = senderPrivateKey.PublicKey;
          

          # Address

          You can create an address from a public key:

          // Specify the sender public key.
          var senderPublicKey = "PASTE_THE_SENDER_PUBLIC_KEY_HERE";
          
          /* 
          Get the account address from the public key.
          NOTE: Ensure the specified network matches the node instance configuration:
          - `MainNet`.
          - Or `TestNet`.
          - Or `StageNet`.
          */
          var senderAddress = Address.FromPublicKey(
              ChainIds.TestNet, 
              senderPublicKey
          );
          
          Send Transactions
          Interact With Node
          Send Transactions
          Interact With Node