> For the complete documentation index, see [llms.txt](https://docs.validationcloud.io/staking/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.validationcloud.io/staking/ethereum/staking-tutorial/api/setting-up-a-wallet.md).

# Setting up a Wallet

The code snippet below returns an ethers wallet constructed from a private Ethereum key.&#x20;

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.

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

  return new ethers.Wallet(privateKey);
}
```
