All Products
Search
Document Center

Blockchain as a Service:Base64 Encoding and Decoding Library

Last Updated:Mar 31, 2026

The Base64 encoding and decoding library provides two built-in functions for BaaS smart contracts: base64_encode and base64_decode. Use these functions to encode strings as MIME Base64 or decode Base64-encoded strings back to their original form — for example, when generating checksums or building verification signatures on-chain.

Function examples

function test_base64_decode() returns (bool , string memory)
{
    string memory name = "aHR0cDovL3Rlc3RfYmFzZTY0IH4hQCMkJQ==";
    return base64_decode(name);
}

function test_base64_encode() returns (bool , string memory)
{
    string memory name = "http://test_base64 ~! @#$%";
    return base64_encode(name);
}

base64_decode

Decodes a MIME Base64-encoded string and returns the original data.

Signature

base64_decode(string data) returns(bool result, string memory data);

Request parameters

NameRequiredTypeDescription
dataYesstringThe Base64-encoded string to decode.

Response parameters

ParameterTypeDescription
resultboolIndicates whether the call succeeded. true indicates success; false indicates failure.
datastringThe decoded string.

base64_encode

Encodes a string using MIME Base64 encoding.

Signature

base64_encode(string data) returns(bool result, string memory data);

Request parameters

NameRequiredTypeDescription
dataYesstringThe string to encode.

Response parameters

ParameterTypeDescription
resultboolIndicates whether the call succeeded. true indicates success; false indicates failure.
datastringThe Base64-encoded string.