Serializers
Encode objects into CBOR or bech32 format.
In smart contract manipulations, serialization is a crucial process that encode data structures or objects into a format that can be easily stored or transmitted and later reconstructed. Below are utilities to help serialize various Cardano smart contracts components.
Serialize Native Script
The function serializeNativeScript allows you to provide the nativeScript with an option of networkId and stakeCredentialHash , returns:
- Bech32 address
- Script Cbor
pubKeyHash with the deserializeAddress then serialize the native script to a bech32 address and script Cbor. To read more on deserializeAddress.Serialize Native script into bech32 address
Serialize Plutus Script
The function serializePlutusScript allows you to provide the plutusScript with an option of networkId and stakeCredentialHash, returns:
- Bech32 address
Serialize Plutus script into bech32 address
Serialize Address Object
Serialize address in Cardano data JSON format into bech32 address with serializeAddressObj().
First you need to create an address object with pubKeyAddress() or scriptAddress().
pubKeyAddress() accepts the following parameters:
scriptAddress() accepts the following parameters:
serializeAddressObj() accepts the following parameters:
Serialize address in Cardano data JSON format into bech32 address
Serialize Pool ID
The function serializePoolId allows you to provide the pubKeyHash i.e (pool Hash), returns:
- Pool Id
Resolve the pool ID from hash
Serialize Reward Address
Serialize a script hash or key hash into bech32 reward address.
The function serializeRewardAddress allows you to provide either the scriptHash or pubKeyHash, specifying isScriptHash as true if a scriptHash was provided and false if a pubKeyHash was provided. Additionally, you can specify the networkId The function returns:
- Bech32 reward address
pubKeyHash or scriptHash into a Bech32 reward address.Serialize a script hash or key hash into bech32 reward address