Solana DocumentationSurfpoolInfrastructure as CodeStandard Library

Base64 Functions

encode_base64

encode_base64 encodes a buffer or string as a base64 string.

Inputs

NameTypeDescription
valuebuffer, string, addonThe buffer or string to encode. Strings starting with '0x' are decoded as hex; otherwise, raw UTF-8 bytes are used.

Output

NameTypeDescription
valuestringThe input, encoded as a base64 string
output "encoded" {
value = encode_base64("0x48656c6c6f20776f726c6421")
}
// > encoded: SGVsbG8gd29ybGQh

decode_base64

decode_base64 decodes a base64 encoded string and returns the result as a buffer.

Inputs

NameTypeDescription
base64_stringstringThe base64 string to decode

Output

NameTypeDescription
valuebufferThe decoded base64 string, as a buffer
output "decoded" {
value = decode_base64("SGVsbG8gd29ybGQh")
}
// > decoded: 0x48656c6c6f20776f726c6421

Is this page helpful?

Table of Contents

Edit Page
© 2026 Solana Foundation. All rights reserved.