# Adding contract owned assets as inputs to transactions

**URL:** <https://forum.fuel.network/t/adding-contract-owned-assets-as-inputs-to-transactions/5168>\
**Category:** Sway\
**Created:** [April 23, 2024, 10:06pm UTC](https://forum.fuel.network/t/adding-contract-owned-assets-as-inputs-to-transactions/5168 "2024-04-23T22:06:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serafim](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@Serafim](https://forum.fuel.network/u/Serafim)\
**Post date:** [April 23, 2024, 10:06pm UTC](https://forum.fuel.network/t/adding-contract-owned-assets-as-inputs-to-transactions/5168/1 "2024-04-23T22:06:15Z")

</div>

Hello Fuel team!  
Let’s say I have a following function:

```auto
pub fn checkAssetOwnership(checked_asset: AssetId) -> bool {
    let num_inputs = input_count().as_u64();
    let mut i = 0;
    while i < num_inputs {
        match input_type(i) {
            Input::Coin => {
                let asset_id = input_asset_id(i).unwrap();
                if asset_id == checked_asset {
                    return true;
                }
            },
            _ => {},
        }
        i = i + 1;
    }
    false

```

Let’s consider that I have another contract which minted an NFT and owns it.  
I wish to send a transaction from that contract to another one to check the ownership using the function above (attaching the input). Is there any way of how I can send an Input from a contract address to check the ownership? If it’s not possible, could you please suggest any alternatives (if any) to achieve that.

Thank you!

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [April 24, 2024, 11:13pm UTC](https://forum.fuel.network/t/adding-contract-owned-assets-as-inputs-to-transactions/5168/2 "2024-04-24T23:13:00Z")

</div>

Hey @Serafim thanks for the question! I’m getting input on the Sway standards team as to how you should go about this.

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [April 26, 2024, 3:03pm UTC](https://forum.fuel.network/t/adding-contract-owned-assets-as-inputs-to-transactions/5168/3 "2024-04-26T15:03:09Z")

</div>

Please let me know if this answers your question because I have a feeling I’m misunderstanding your question but…

Contracts can utilize `std::context::balance_of` to retrieve the balance associated with a specific `contractid` for a given `assetid`.

For example, you can see how it is implemented in this code snippet: [sway/sway-lib-std/src/context.sw at 55140ba8d534a805f9080b7fa4e9ba8fc99e8d31 · FuelLabs/sway · GitHub](https://github.com/FuelLabs/sway/blob/55140ba8d534a805f9080b7fa4e9ba8fc99e8d31/sway-lib-std/src/context.sw#L55).

I hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![Serafim](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@Serafim](https://forum.fuel.network/u/Serafim)\
**Post date:** [May 1, 2024, 1:17pm UTC](https://forum.fuel.network/t/adding-contract-owned-assets-as-inputs-to-transactions/5168/4 "2024-05-01T13:17:02Z")

</div>

Hey @calldelegation! Seems that the answer solves the problem I’ve got, thank you!

For anyone who has the same question as I did, it might be useful to read the following question to understand how balance is stored for contracts and what’s the difference between account balance and contract balance: [How to get the balance of an EOA address in sway](https://forum.fuel.network/t/how-to-get-the-balance-of-an-eoa-address-in-sway/1360)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [May 22, 2024, 9:17am UTC](https://forum.fuel.network/t/adding-contract-owned-assets-as-inputs-to-transactions/5168/5 "2024-05-22T09:17:38Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
