Skip to content

write a how to on black box testing uplc #128

@aleeusgr

Description

@aleeusgr

I would like to know if I can test a smart contract written in Plutus with the Helios library.

If you want to run automated tests on a validator using Helios Emulator, try my toolbox:

Hmm, I think I will need to look for something else. Unless I can find a way to port CBOR encoded Plutus script into Helios

cschmitz

14/07/2023 12:01
That should be possible
The tx builder only really cares about UplcProgram, which can be deserialized from cbor
And the emulator only cares about the output of the tx builder
No need to port anything to Helios

Implementation

omething like

const uplcProgram = UplcProgram.fromCbor("");

// if it is a minting policy
const mph = uplcProgram.mintingPolicyHash;
tx.mintTokens(mph, [[, ], ...], );
tx.attachScript(uplcProgram);

// if you want to send to a spending validator
const vh = uplcProgram.validatorHash;
const scriptAddress = Address.fromValidatorHash(vh);

tx.addOutput(new TxOutput(
scriptAddress,
new Value(1000000)
);

// if you want to spend from a validator
tx.addInput(await network.getUtxos(scriptAddress)[0], );
tx.attachScript(uplcProgram);
https://discord.com/channels/997177025972424815/997177026517676055/1129286387150106688

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions