Convertir un ScVal a otro tipo
El valor del contrato Soroban (ScVal
) es un tipo personalizado definido dentro del entorno de ejecución Soroban que representa otros tipos de datos como cadenas, bytes y estructuras más complejas utilizadas dentro de contratos inteligentes en un formato que el entorno de ejecución Soroban puede procesar, almacenar y recuperar de manera eficiente.
ScVal a bytes
- JavaScript
- Python
// An ScVal bytes value
const myScVal = StellarSdk.xdr.ScVal.fromXDR("AAAADQAAAARQ/8AB", "base64");
// Convert the ScVal to a Buffer
const bytesFromScVal = StellarSdk.scValToNative(myScVal);
# Convert the ScVal to bytes
bytes_from_sc_val = stellar_sdk.scval.from_bytes("AAAADQAAAARQ/8AB")
ScVal a dirección
- JavaScript
- Python
// An ScVal Address value
const myScVal = StellarSdk.xdr.ScVal.fromXDR(
"AAAAEgAAAAAAAAAAmds+PBjjrhZAv1aCM4n4EbU6ycAbK5HqxcUsumDFyf4=",
"base64",
);
// Convert the ScVal to an Address
const addressFromScVal = StellarSdk.Address.fromScVal(myScVal);
# Convert the ScVal to address
address_from_sc_val = stellar_sdk.scval.from_address("AAAAEgAAAAAAAAAAmds+PBjjrhZAv1aCM4n4EbU6ycAbK5HqxcUsumDFyf4=")
ScVal a cadena
- JavaScript
- Python
// An ScVal string value
const myScVal = StellarSdk.xdr.ScVal.fromXDR(
"AAAADgAAAA9IZWxsbywgU3RlbGxhciEA",
"base64",
);
// Convert the ScVal to a string
const stringFromScVal = StellarSdk.scValToNative(myScVal);
# Convert the ScVal to a string
string_from_sc_val = stellar_sdk.scval.from_string("AAAADgAAAA9IZWxsbywgU3RlbGxhciEA").decode()
Guías en esta categoría:
📄️ Convertir una dirección a otros tipos
Convertir una dirección a otros tipos
📄️ Convertir de bytes a otros tipos
Convertir de bytes a otros tipos
📄️ Convertir un ScVal a otro tipo
Convertir un ScVal a otro tipo
📄️ Convertir una cadena a otros tipos
Convertir una cadena a otros tipos