<p>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 .</p>

CC BY-SA 4.0
2022-02-09T11:40:33.340Z
2022-02-09T11:40:33.340Z
Mantas Andriuška
<p>I'm trying to add lovelaces + native assets to input as multiAsset. However I get <code>Inputs do not conform to this spec or are otherwise invalid.</code>
Here is my code:</p>
<pre><code>    const assetsToSend = this.S.MultiAsset.new();
    const assets = this.S.Assets.new();
    const policyStr = &quot;17830caa477d5eac7a4b6c123d98fa232e6e921368b01b7cd0bdfce6&quot;
    
    const assetStr = &quot;17830caa477d5eac7a4b6c123d98fa232e6e921368b01b7cd0bdfce641414441&quot;;
    const assetName = this.S.AssetName.new(Buffer.from(assetStr.slice(56), &quot;hex&quot;));
    
    // 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, &quot;hex&quot;)),
        assets
    );
    // Setting value with multiasset
    assetsValue.set_multiasset(assetsToSend)
    
    txBuilder.add_input(
        this.S.Address.from_bech32(&quot;addr_test1qqcula4fd6nr92zx2jyl59eqy574f8uhg98dhfys7zer23p03az6tzlxgrxk5a9ev6taetv6ljkyr7rcx4rljm7qya2syeq06w&quot;),
        this.S.TransactionInput.new(
            this.S.TransactionHash.from_bytes(
                Buffer.from(&quot;707c0ad2499b278e48bc8e42b902ec8ccea8e83e87175f57f4349241cd5a8417&quot;, &quot;hex&quot;)
            ), // tx hash
            0, // index
        ),
        assetsValue
        // this.S.Value.new(this.S.BigNum.from_str('1500000')) 
    );
</code></pre>

<cardano-serialization-lib>
How to add multiasset as input to txBuilder?
# How to add multiasset as input to txBuilder?

(Asked by: username_0 on 2022-02-08)

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')) 
    );

**Tags:** cardano-serialization-lib

---

## 1 answers

### Answer by username_0 on 2022-02-09. Score: 0 | Accepted answer

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 .


---

