3

Free Everscale Solidity. How to work with responsible functions? How to wait for callback in correct way and check the contract execution result from sdk?

For example I have the contracts (which does nothing userful). How to wait in correct way in my application a writing to a_ and b_ variables?

contract A {
 uint256 a_;
 string b_;

 function foo(uint256 a, string b, address c) extenal {
  tvm.accept();
  B(c).bar{value: 1 ton, callback: A.callback}(a, b);
 }

 function callback(uint256 a, string b) external {
  tvm.accept();
  a_ = a;
  b_ = b;
 }
}

contract B {
 function bar(uint256 a, string b) exrnal responsible returns (uint256, string) {
  return { value: 0, bounce: false, flag: 64 } (a, b);
 }
}
Léo Natan
  • 56,823
  • 9
  • 150
  • 195
koda
  • 47
  • 3

1 Answers1

2

Well, you can know when the first transaction is completed using wait_for_transaction.

One of the parameters returned by wait_for_transaction is out_messages, a list of all messages created by this transaction. In this case is should be one, the call to callback.

I expect it would be possible to use wait_for_transaction on the these messages.

I haven't tried this though and it is possible wait_for_transaction is only for external messages. In that case maybe using transactions iterator would help instead.

Noam
  • 333
  • 1
  • 18