👨🏽‍💻

Для разработчиков

/// @notice Example of invoking function of msig DeBot. Allows to transfer tons from msig wallet to recipient address.

    function invokeTransaction(address sender, address recipient, uint128 amount, bool bounce, TvmCell payload) public {
        //TODO: implement certain DeBot scenario.
    }

    /// @notice Allows to create internal message to invoke `invokeTransaction` DeBot function. 
    /// The message can be sent to DeBot by external app or other DeBots to run certain scenario.
    /// Parameters: define arguments for your invoke function.
    /// Returns: return internal message packed to Cell.

    function getInvokeMessage(address sender, address recipient, uint128 amount, bool bounce, TvmCell payload) public pure
        returns(TvmCell message) {
        TvmCell body = tvm.encodeBody(MsigDebot.invokeTransaction, sender, recipient, amount, bounce, payload);
        TvmBuilder message_;
        // Pack internal message header (see TON blockchain spec for TLB-scheme).
        message_.store(false, true, true, false, address(0), address(this));
        message_.storeTons(0);
        message_.storeUnsigned(0, 1);
        message_.storeTons(0);
        message_.storeTons(0);
        message_.store(uint64(0));
        message_.store(uint32(0));
        message_.storeUnsigned(0, 1); //init: nothing$0
        message_.storeUnsigned(1, 1); //body: right$1
        // Pack encoded message body
        message_.store(body);
        message = message_.toCell();
    }
Example, Multisig DeBot

1. Support invoking in DeBot

Write and make a public function in DeBot that can be invoked by other DeBots or by DeBot Browser and that will accept all necessary parameters for certain scenario.

2. Generate message for DeBot with predefined params.

Write and implement a get-method in DeBot that will accept values for required parameters of invoke function (defined in Step 1) and pack them into internal message to DeBot.

Note: get-method must return message argument of type cell

3. Call get-method

Save message argument returned by this method and recode it as base64url to be compatible with URL scheme.

4. Create TON Surf link

Use link template:

https://uri.ton.surf/debot?address=<address>&message=<message>

address — address of DeBot.

message — message to DeBot.

5. Open link

Open link in Browser or generate QRCode for it and scan it by TON Surf.

Example

  1. Run script invoke_msg.sh in the multisig directory (sources from example):
./invoke_msg.sh 0:606545c3b681489f2c217782e2da2399b0aed8640ccbcf9884f75648304dbc77 1000000000 true

2. Copy message printed to the terminal and insert it to the link after message= key.

Note: run script without arguments to see help

3. Build a link:

https://uri.ton.surf/debot?address=0:09403116d2d04f3d86ab2de138b390f6ec1b0bc02363dbf006953946e807051e&message=te6ccgEBAwEAsQABo2gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAlAMRbS0E89hqst4TizkPbsGwvAI2Pb8AaVOUboBwUeAAAAAAAAAAAAAAAAAAMABAa0gCd0zgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAGBlRcO2gUifLCF3guLaI5mwrthkDMvPmIT3VkgwTbx3AAAAAAAAAAAAAAAAO5rKAMCAAA

Enjoy!

Остались вопросы?