> For the complete documentation index, see [llms.txt](https://affection.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://affection.gitbook.io/docs/bots-and-scripts/core-functions/load_wallet.md).

# load\_wallet

## Function

```python
def load_wallet(address, secret):
    file_path = "./data/wallets/{}/keystore".format(address)
    if not os.path.exists(file_path):
        raise FileNotFoundError
    keystore = "\n".join([line.strip() for line in open(file_path, 'r+')])
    private_key = web3.eth.account.decrypt(keystore, secret)
    return web3.eth.account.from_key(private_key)
```

## Description

* Set the file path for the wallet’s keystore
* If the file doesn’t exist then raise FileNotFoundError
* Load the keystore as a string
* Decrypt the keystore with secret
* Return the account


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://affection.gitbook.io/docs/bots-and-scripts/core-functions/load_wallet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
