Skip to content

Inaccurate Value generated in offchain code datum #93

@arressaye

Description

@arressaye

I have datum defined in my contract as such

struct Datum {
    sender: PubKeyHash
    recipient: PubKeyHash
    exchange_for: Value
}

When I generate the datum in offchain code like so:

const heliosDatum = new EscrowProgram.types.Datum(
    helios.hexToBytes(helios.Address.fromBech32(sender).pubKeyHash.hex),
    helios.hexToBytes(helios.Address.fromBech32(recipient).pubKeyHash.hex),
    helios.Value.fromCbor(helios.hexToBytes(recipientValue))
  );

Note that recipientValue above is a CBOR hex string of a Value created from Cardano Serialization Library and not a Helios Value therefore it had to be converted.

The resulting Value of the datum contains only the non-ADA assets even though the recipientValue is the CBOR hex string of the full value I'm interested in, including ADA. Indeed if I run console.log(helios.Value.fromCbor(helios.hexToBytes(recipientValue)).lovelace.toString()); I do get the full value including ADA and native tokens printed to console. The ADA portion just doesn't get included in the datum somehow.

I've tested a few different scenarios and it seems like if recipientValue contained only ADA or only native tokens, the Datum will be correct. However if it included both ADA and native tokens, the Value in the Datum will ignore the ADA portion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions