2

I follow this instruction to call smart contracts from DeBot using the message argument in the Surf URI:

https://tonlabs.notion.site/For-developers-f347bd4095f74c9d9e2bd313c666905d

It works ok, but it produces external messages. My guess is that the difference is in headers. How should I modify them to send an internal message using the same scheme?

Norton
  • 83
  • 4

3 Answers3

2

DeBot cannot send internal message.

enter image description here

DeBot have 3 special features:

  1. calling — get-methods of target smart contracts;
  2. calling — external functions of target smart contracts onchain;
  3. invoking — other DeBot in a local environment.

See DeBot Special Features for more details.

ilyar
  • 1,331
  • 12
  • 21
2

Yes, DeBots themselves cannot do it, so people do the following trick:

  1. Pack debot method arguments into payload: https://github.com/tonlabs/debots/blob/d8111db9eb5d8c42a362a0d34a4dea38f6789eec/accman/AccMan.sol#L257

  2. Run sendTransction with the address of the current DeBot (to) and the address of a wallet (from). The wallet aka smart contract must obviously have sendTransction.

The external message is received by the wallet, and the multisig sends an internal message to the method in payload.

  1. Once the DeBot receives this internal message, it can tunnel them to other smart contracts.

The step can be simplified, so that sendTransction is sent directly to the smart contract which requires internal message by providing the correct payload parameters (method name and params).

Norton
  • 83
  • 4
1

I think previous answers are indeed "best practice", but still incorrect. Of course, you CAN make internal messages without any additional Msig. DeBot is a smart-contract too. You just have to do the call like this:

address myDebotAddr = address(this);
IMyDebot(myDebotAddr).myFunction{...}( ... );

DeBot will call his own contract that lies in blockchain. Then in the function myFunction() you should:

  1. have tvm.accept();
  2. do the internal call that you need

Thus the execution of myFunction() will happen in blockchain, not locally. Still, you will have to add funds to debot balance. So, it's not a "best practice" for widely used DeBots.

Dima Yankin
  • 365
  • 1
  • 12