> For the complete documentation index, see [llms.txt](/llms.txt).

- Snap

# snap_getFile

Gets a static file's content in UTF-8, Base64, or hexadecimal.

The file must be specified in [the Snap's manifest file](https://metamask-docs-git-imp-agt-scr-90-100-consensys-ddffed67.vercel.app/snaps/features/static-files/).

## Parameters[​](#parameters "Direct link to Parameters")

object

required

An object containing the parameters for the `snap_getFile` method.

### path

string

required

The path to the file, relative to the Snap's package directory (that is, one level above `src`).

### encoding

"base64" | "hex" | "utf8"

The encoding to use when retrieving the file. Defaults to `base64`.

## Returns[​](#returns "Direct link to Returns")

string | null

The file content as a string in the requested encoding, or `null` if the file does not exist.

## Example

- Manifest
- Usage

```
{
  "source": {
    "files": ["./files/my-file.bin"]
  }
}

```

```
const contents = await snap.request({
  method: 'snap_getFile',
  params: {
    path: './files/myfile.bin',
    encoding: 'hex',
  },
})

// '0x...'
console.log(contents)

```
