Solana DocumentationSurfpoolInfrastructure as CodeStandard Library

Base58 Functions

encode_base58

encode_base58 encodes a buffer or string as a base58 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 base58 string
output "encoded" {
value = encode_base58("0xaca1e2ae0c54a9a8f12da5dde27a93bb5ff94aeef722b1e474a16318234f83c8")
}
// > encoded: CctJBuDbaFtojUWfQ3iEcq77eFDjojCtoS4Q59f6bUtF

decode_base58

decode_base58 decodes a base58 encoded string and returns the result as a buffer.

Inputs

NameTypeDescription
base58_stringstringThe base58 string to decode

Output

NameTypeDescription
valuebufferThe decoded base58 string, as a buffer
output "decoded" {
value = decode_base58("CctJBuDbaFtojUWfQ3iEcq77eFDjojCtoS4Q59f6bUtF")
}
// > decoded: 0xaca1e2ae0c54a9a8f12da5dde27a93bb5ff94aeef722b1e474a16318234f83c8

Is this page helpful?

Table of Contents

Edit Page
© 2026 Solana Foundation. All rights reserved.