snap_getFile
Description
Gets a static file's content in UTF-8, Base64, or hexadecimal.
The file must be specified in the Snap's manifest file.
Parameters
path
stringrequiredThe path to the file, relative to the Snap's package directory
(that is, one level above src).
encoding
"base64" | "hex" | "utf8" | nullThe encoding to use when retrieving the file. Defaults to base64.
Returns
string
The file content as a string in the requested encoding.
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);