Skip to content

ptb

Programmable Transaction Blocks are core feature in sui blockchain to call multi move functions within a single transcation.

with deepauto framework, writing ptb will be more easy and straightforward

  • frist, you will have to use set_config to setup ptb env variables
  • second, you can call directly to deepauto generated ptb function wrappers
typescript
import { set_config, new_sui_client, sign_execute_transaction } from "@deepmove/sui";
import { Transaction } from "@mysten/sui/transactions";
import { AdminCap, setup } from "./wrappers/dependencies/MultiChainWalrus/setup";
import { State } from "./wrappers/dependencies/MultiChainWalrus/state";

set_config({
    network: "testnet",
    packages: {
        MultiChainWalrus: "0x8759091c5fd8de144c2cfa02b12b827e415c037e6629cad93af6251552e81c15"
    },
    objects: {
        state: "0xcff32113cc945f9847ccc04d99be33ce4fd3afb2e53e08a4b6feb46241842d95",
        adminCap: "0x27814b5bd6b5b8953367a61402e02ff56390f8f8a440e3b745f921b7a459c637"
    }
});

async function set_transceiver_peer() {
    const client = new_sui_client();

    if (!client) {
        console.error("sui client null");
        return;
    }

    const tx = new Transaction();

    let peer_address = "0x39467cF8A6dA53b611A917e669ea8a40C33FfaaC";
    let address_bytes = new HexString(peer_address).toUint8Array();

    let op_chainid = 10005;
    let eth_chainid = 10002;
    setup.set_transceiver_peer(tx, AdminCap.from_key("adminCap"), State.from_key("state"), eth_chainid, Array.from(address_bytes));

    const result = await sign_execute_transaction(client, tx);

    console.log(result)
}

async function go() {
    set_transceiver_peer();
}

go()

References

https://docs.sui.io/concepts/transactions/prog-txn-blockshttps://docs.sui.io/guides/developer/sui-101/building-ptb

Released under the MIT License.