Contract call fails with error like "Assets Forwarded To Non Payable Method"

Hi there
I’m trying to attach payment using rust SDK v0.37.1
And this code returns this error

let call_params = CallParameters::new(Some(args.amount0), Some(args.asset0), None);
        let tx_params = TxParameters::new(Some(100), Some(100_000_000), Some(0));
        contract
            .methods()
            .create_order(args.asset1, args.amount1, args.matcher_fee)
            .call_params(call_params)
            .unwrap()
            .tx_params(tx_params)
            .append_variable_outputs(1)
            .call()
            .await
running 1 test
thread 'local_tests::main_test::main_test' panicked at 'called `Result::unwrap()` on an `Err` value: AssetsForwardedToNonPayableMethod', tests/utils/cotracts_utils/limit_orders_utils.rs:112:14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/065852def0903296da33a9eaf557f230bcf3a61a/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/065852def0903296da33a9eaf557f230bcf3a61a/library/core/src/panicking.rs:64:14
   2: core::result::unwrap_failed
             at /rustc/065852def0903296da33a9eaf557f230bcf3a61a/library/core/src/result.rs:1790:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/065852def0903296da33a9eaf557f230bcf3a61a/library/core/src/result.rs:1112:23
   4: integration_tests::utils::cotracts_utils::limit_orders_utils::limit_orders_abi_calls::create_order::{{closure}}
             at ./tests/utils/cotracts_utils/limit_orders_utils.rs:108:9
   5: integration_tests::local_tests::main_test::main_test::{{closure}}
             at ./tests/local_tests/main_test.rs:42:75
   6: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/065852def0903296da33a9eaf557f230bcf3a61a/library/core/src/future/future.rs:125:9
   7: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/065852def0903296da33a9eaf557f230bcf3a61a/library/core/src/future/future.rs:125:9
   8: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/scheduler/current_thread.rs:541:57
   9: tokio::runtime::coop::with_budget
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/coop.rs:102:5
  10: tokio::runtime::coop::budget
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/coop.rs:68:5
  11: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/scheduler/current_thread.rs:541:25
  12: tokio::runtime::scheduler::current_thread::Context::enter
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/scheduler/current_thread.rs:350:19
  13: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/scheduler/current_thread.rs:540:36
  14: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/scheduler/current_thread.rs:615:57
  15: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/macros/scoped_tls.rs:61:9
  16: tokio::runtime::scheduler::current_thread::CoreGuard::enter
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/scheduler/current_thread.rs:615:27
  17: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/scheduler/current_thread.rs:530:19
  18: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/scheduler/current_thread.rs:154:24
  19: tokio::runtime::runtime::Runtime::block_on
             at /Users/alexey/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/runtime.rs:282:47
  20: integration_tests::local_tests::main_test::main_test
             at ./tests/local_tests/main_test.rs:88:5
  21: integration_tests::local_tests::main_test::main_test::{{closure}}
             at ./tests/local_tests/main_test.rs:11:22
  22: core::ops::function::FnOnce::call_once
             at /rustc/065852def0903296da33a9eaf557f230bcf3a61a/library/core/src/ops/function.rs:250:5
  23: core::ops::function::FnOnce::call_once
             at /rustc/065852def0903296da33a9eaf557f230bcf3a61a/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test local_tests::main_test::main_test ... FAILED

Hi, You should to add decorator #[payable] into each method in sway code

1 Like

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