'How to call run-local function from debot?
How to call run-local (without sending a message) function of another contract from debot? For example, for getting a public variable.
Solution 1:[1]
This was useful for me.
In debot:
- Create interface for function of another contract with function (if public variable too).
interface IOther {
function funcName()
external returns(uint);
}
- Build the message and send it.
function runLocal() public{
optional(uint256) pubkey = 0;
address remoteContract = address.makeAddrStd(0, 0xceaa3bc6b00cf2b1e750dae2dd94d246a126a989009a3fb3bb73bea1a48b3b);
TvmCell message = tvm.buildExtMsg({
abiVer: 2,
callbackId: tvm.functionId(onSuccessFuncName),
onErrorId: tvm.functionId(onErrorFuncName),
time: uint64(now),
dest: remoteContract,
call: {
IOther.funcName
}
});
tvm.sendrawmsg(message, 1);
}
function onSuccessFuncName(uint response) public{
/* working with response from remote contract */
}
function onErrorFuncName() public{
/* catch error */
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mikki Ukraine |