LogoLogo
DashboardBlogNode API DocsContact
  • Staking
    • Overview
    • FAQ
  • Ethereum
    • Staking Tutorial
      • API
        • Prerequisites
        • Authenticating with Auth0
        • Setting up a Wallet
        • Get Staking Transaction
        • Signing a Transaction
        • Broadcast Transaction
        • Full Code
    • Staking API Reference
      • Authentication
      • Get Validators
      • Stake Transaction
      • Broadcast Transaction
      • Exit Validators
      • Presigned Exit Request
Powered by GitBook
On this page
  1. Ethereum
  2. Staking Tutorial
  3. API

Setting up a Wallet

Initializing an ethers.js wallet constructed from a private Ethereum key.

The code snippet below returns an ethers wallet constructed from a private Ethereum key.

Note: For secure production environments, we recommend utilizing a secrets manager or vault to invoke the private key, instead of a plain-text environment variable.

function getWallet() {
  const privateKey = process.env.PRIVATE_KEY;
  if (!privateKey) {
    throw 'PRIVATE_KEY environment variable must be defined';
  }

  return new ethers.Wallet(privateKey);
}
PreviousAuthenticating with Auth0NextGet Staking Transaction

Last updated 1 year ago