1

Adding #[ink(payable)] to a #[ink(message)] prevents ink_env::debug_println! messages to be logged in console when executing the smart contract call.

Any additional config needed in this case to have ink_env::debug_println! in console?

1
  • Are you runining node with -dev --tmp -lruntime::contracts=debug flags ?
    – P.Ossun
    May 3, 2022 at 7:51

1 Answer 1

1

Debug messages are only emitted during a dry run (query), not during the actual transaction (tx)(Source).

When you're calling the contract, first query it. Then perform your transaction if there are no error messages.

e.g.

public async transaction(signer: Signer, method: string, args: any[]): Promise<Partial<TransactionResponse>> {

    // View any debug in substrate logs and catch any errors here
    const queryBeforeTx = await await this.contract.query[method](this.account.address, {}, ...args);

    // Then run your transaction
    const extrinsic = this.contract.tx[method]({}, ...args);
4
  • That's true for polkadotjs-UI. But you can print to the console of the substrate node & it works with tx as well
    – P.Ossun
    May 4, 2022 at 7:31
  • Personally, when I submit a tx from the polkadot apps interface, I don't get any ink! debug on the substrate node. When I submit a query, I do get ink! debug on the substrate node.
    – forgetso
    May 4, 2022 at 10:10
  • This is when I'm running substrate with log flags -lerror,runtime::contracts=debug
    – forgetso
    May 4, 2022 at 10:24
  • 2
    just tested with polkadotjs & you are right. I got log on query but not on tx
    – P.Ossun
    May 4, 2022 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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