Solana documentatieInfrastructure als CodeStandaardbibliotheek

Hex-functies

encode_hex

encode_hex codeert een buffer of string als een hexadecimale string met het voorvoegsel 0x.

Invoer

NaamTypeBeschrijving
valuebuffer, string, addonDe te coderen buffer of string. Strings die beginnen met '0x' worden gedecodeerd als hex; anders worden onbewerkte UTF-8-bytes gebruikt.

Uitvoer

NaamTypeBeschrijving
valuestringDe invoer in hexadecimale weergave met het voorvoegsel 0x
output "encoded_hex" {
value = encode_hex("hello, world")
}
// > encoded_hex: 0x68656c6c6f2c20776f726c64

decode_hex

decode_hex decodeert een hexadecimale string en retourneert het resultaat als een buffer.

Invoer

NaamTypeBeschrijving
hex_stringstringDe te decoderen hex-string (met of zonder het voorvoegsel 0x)

Uitvoer

NaamTypeBeschrijving
valuebufferDe gedecodeerde hex-string als buffer
output "decoded_hex" {
value = decode_hex("0x68656c6c6f2c20776f726c64")
}
// > decoded_hex: 0x68656c6c6f2c20776f726c64

Is this page helpful?

Inhoudsopgave

Pagina Bewerken
© 2026 Solana Foundation. Alle rechten voorbehouden.