# Println! macro doesn't work printing values

**URL:** <https://forum.fuel.network/t/println-macro-doesnt-work-printing-values/5965>\
**Category:** Rust SDK\
**Tags:** feedback, faqs\
**Created:** [June 21, 2024, 7:06am UTC](https://forum.fuel.network/t/println-macro-doesnt-work-printing-values/5965 "2024-06-21T07:06:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eesheng](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@eesheng](https://forum.fuel.network/u/eesheng)\
**Post date:** [June 21, 2024, 7:06am UTC](https://forum.fuel.network/t/println-macro-doesnt-work-printing-values/5965/1 "2024-06-21T07:06:01Z")

</div>

I am facing this error, where unwrapping a call cannot returns this error. I just want to print the returned value…

```auto
`FuelCallResponse<fuels::types::Address>` cannot be formatted with the default formatted

```

My ./test/harness.rs

```auto
use fuels::{prelude::*, types::ContractId};

abigen!(Contract(name="MyContract", abi="out/debug/test_asset-abi.json"));

#[tokio::test]
async fn test_harness() {
    // Test code here
    let (instance, _id) = get_contract_instance().await;

    let result = instance.methods().deposit().call().await.unwrap();
    let result2 = instance.methods().test_deposit_asset_id_same_generated().call().await.unwrap();
    let _str_from_address: &str = result.to_string().as_str();
    let r2_str_from_address: &str = result2.to_string().as_str();
    println!("{:?}",_str_from_address);
    println!("{:?}",r2_str_from_address);

}

async fn get_contract_instance() -> (MyContract<WalletUnlocked>, ContractId) {
    // Launch a local network and deploy the contract
    let wallets = launch_custom_provider_and_get_wallets(
        WalletsConfig::new(
            Some(3), /* Three wallets */
            Some(1), /* Single coin (UTXO) */
            Some(1_000_000_000), /* Amount per coin */
        ),
        None,
        None,
    )
    .await
    .unwrap();
 
    let wallet = wallets.get(0).unwrap().clone();
    
    let id = Contract::load_from(
        "./out/debug/test_asset.bin",
        LoadConfiguration::default(),
    )
    .unwrap()
    .deploy(&wallet, TxPolicies::default())
    .await
    .unwrap();
 
    let instance = MyContract::new(id.clone(), wallet);
 
    (instance, id.into())
}

```

My sway contract:

```auto
// Constant Product AMM - Uniswap V2.
contract;

use std::{
    constants::ZERO_B256,
    hash::sha256,
    asset::transfer,
    hash::Hash,
    asset_id::AssetId,
    asset::{
        burn,
        mint_to,
    },
    contract_id::ContractId,
    call_frames::{
        msg_asset_id,
    },
    context::msg_amount,
    string::String,
};
 

abi MyContract {
    #[storage(read, write)]
    fn deposit()-> Address;
    
    #[storage(read)]
    fn test_deposit_asset_id_same_generated() -> Address;
}

impl MyContract for Contract {
    #[storage(read, write)]
    fn deposit() -> Address {

        let owner = msg_sender().unwrap();
        let asset_id = msg_asset_id().bits();
        let address_from_b256: Address = Address::from(asset_id);
        address_from_b256
    }

    #[storage(read)]
    fn test_deposit_asset_id_same_generated() -> Address {
        let token_id = b256::zero();
        let token_address = ZERO_B256;
        let sub_id = sha256((token_address, token_id));

        
        let asset_id: b256 = AssetId::new(ContractId::this(), sub_id).bits();
        let address_from_b256: Address = Address::from(asset_id);
    
        address_from_b256
        
    }

}

```

---

<div class="post-metadata">

**Author:** ![eesheng](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@eesheng](https://forum.fuel.network/u/eesheng)\
**Post date:** [June 21, 2024, 7:07am UTC](https://forum.fuel.network/t/println-macro-doesnt-work-printing-values/5965/2 "2024-06-21T07:07:56Z")

</div>

println! macro doesn’t work at all, why it doesn’t work?

```auto
use fuels::{prelude::*, types::ContractId};

abigen!(Contract(name="MyContract", abi="out/debug/test_asset-abi.json"));

#[tokio::test]
async fn test_harness() {
    // Test code here
    let (instance, _id) = get_contract_instance().await;

    let result = instance. Methods().deposit().call().await. Unwrap().value;
    let result2 = instance. Methods().test_deposit_asset_id_same_generated().call().await. Unwrap().value;
    println!("{:?}",result );
    println!("{:?}",result2 );

}

```

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [June 21, 2024, 10:37am UTC](https://forum.fuel.network/t/println-macro-doesnt-work-printing-values/5965/3 "2024-06-21T10:37:42Z")

</div>

it seems like a rust error to me. could you share your rust version? and also the output for the `fuelup show` from your terminal

---

<div class="post-metadata">

**Author:** ![eesheng](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@eesheng](https://forum.fuel.network/u/eesheng)\
**Post date:** [June 21, 2024, 12:52pm UTC](https://forum.fuel.network/t/println-macro-doesnt-work-printing-values/5965/4 "2024-06-21T12:52:55Z")

</div>

This is my terminal running `cargo test`

```auto
   Compiling test_asset v0.1.0 (/home/lokicheck/Desktop/test_asset)
warning: unused variable: `result2`
  --> tests/harness.rs:12:9
   |
12 | let result2 = instance.methods().test_deposit_asset_id_same_generated().call().await.unwrap().value;
   | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_result2`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: `test_asset` (test "integration_tests") generated 1 warning
    Finished `test` profile [unoptimized + debuginfo] target(s) in 1m 04s
     Running tests/harness.rs (target/debug/deps/integration_tests-c9599d2b0d721b79)

running 1 test
test test_harness ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.53s

```

This is my terminal running `fuelup show`

```auto
Default host: x86_64-unknown-linux-gnu
fuelup home: /home/lokicheck/.fuelup

installed toolchains
--------------------
latest-x86_64-unknown-linux-gnu (default)
nightly-2024-05-28-x86_64-unknown-linux-gnu
testnet-x86_64-unknown-linux-gnu

active toolchain
----------------
latest-x86_64-unknown-linux-gnu (default)
  forc : 0.60.0
    - forc-client
      - forc-deploy : 0.60.0
      - forc-run : 0.60.0
    - forc-crypto : 0.60.0
    - forc-debug : 0.60.0
    - forc-doc : 0.60.0
    - forc-explore : 0.28.1
    - forc-fmt : 0.60.0
    - forc-lsp : 0.60.0
    - forc-tx : 0.60.0
    - forc-wallet : 0.7.1
  fuel-core : 0.26.0
  fuel-core-keygen : 0.26.0

fuels versions
--------------
forc : 0.62.0
forc-wallet : 0.62.0

```

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [June 27, 2024, 11:04am UTC](https://forum.fuel.network/t/println-macro-doesnt-work-printing-values/5965/5 "2024-06-27T11:04:49Z")

</div>

> [@eesheng](#):
>
> This is my terminal running `cargo test`
> 
> ```auto
> Compiling test_asset v0.1.0 (/home/lokicheck/Desktop/test_asset)
> warning: unused variable: `result2`
> --> tests/harness.rs:12:9
> |
> 12 | let result2 = instance.methods().test_deposit_asset_id_same_generated().call().await.unwrap().value;
> | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_result2`
> |
> = note: `#[warn(unused_variables)]` on by default
> 
> warning: `test_asset` (test "integration_tests") generated 1 warning
> Finished `test` profile [unoptimized + debuginfo] target(s) in 1m 04s
> Running tests/harness.rs (target/debug/deps/integration_tests-c9599d2b0d721b79)
> 
> running 1 test
> test test_harness ... ok
> 
> test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.53s
> 
> ```

Looking at the output for the `cargo test` it seems that the test is passing and it is just giving the warning.

And for the `Println`, †he error you are encountering, can you try updating your `result` and `result2` to this

```auto
let result = instance.methods().deposit().call().await.unwrap().value;
let result2 = instance.methods().test_deposit_asset_id_same_generated().call().await.unwrap().value;

```

---

<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:** [July 18, 2024, 7:05am UTC](https://forum.fuel.network/t/println-macro-doesnt-work-printing-values/5965/6 "2024-07-18T07:05:10Z")

</div>

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