2

I'm trying to add lovelaces + native assets to input as multiAsset. However I get Inputs do not conform to this spec or are otherwise invalid. Here is my code:

    const assetsToSend = this.S.MultiAsset.new();
    const assets = this.S.Assets.new();
    const policyStr = "17830caa477d5eac7a4b6c123d98fa232e6e921368b01b7cd0bdfce6"
    
    const assetStr = "17830caa477d5eac7a4b6c123d98fa232e6e921368b01b7cd0bdfce641414441";
    const assetName = this.S.AssetName.new(Buffer.from(assetStr.slice(56), "hex"));
    
    // creating asset value for lovelaces
    const assetsValue = this.S.Value.new(
        this.S.BigNum.from_str('1500000')
    )

    // Inserting Native token
    assets.insert(
        assetName,
        this.S.BigNum.from_str('123')
    );

    // Adding asset to multiasset
    assetsToSend.insert(
        this.S.ScriptHash.from_bytes(Buffer.from(policyStr, "hex")),
        assets
    );
    // Setting value with multiasset
    assetsValue.set_multiasset(assetsToSend)
    
    txBuilder.add_input(
        this.S.Address.from_bech32("addr_test1qqcula4fd6nr92zx2jyl59eqy574f8uhg98dhfys7zer23p03az6tzlxgrxk5a9ev6taetv6ljkyr7rcx4rljm7qya2syeq06w"),
        this.S.TransactionInput.new(
            this.S.TransactionHash.from_bytes(
                Buffer.from("707c0ad2499b278e48bc8e42b902ec8ccea8e83e87175f57f4349241cd5a8417", "hex")
            ), // tx hash
            0, // index
        ),
        assetsValue
        // this.S.Value.new(this.S.BigNum.from_str('1500000')) 
    );

1 Answer 1

0

The code I described above is okay to pass multiassets to TX inputs. It have worked for me with cardano-serialization-lib 10.0.1 .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.