composeTransaction
composeTransaction is a low-level action that passes a raw wave expression to the Kontor composer (together with other required arguments). It has no knowledge of a contract WIT specification. Accordingly, the response is not parsed.
In the below, example, a transfer is composed on the nativeToken contract using a manually serialized wave expression.
import {
nativeToken,
createKontorIndexerClient,
http,
signet,
Instruction,
} from "@kontor/kontor-sdk";
export const indexerClient = createKontorIndexerClient({
chain: signet,
transport: http(),
});
const composeOutputs = await indexerClient.composeTransaction({
account: ["taproot-address", "x-only-public-key"],
utxos: ["txid:vout"],
satsPerVByte: 1,
instruction: Instruction.call({
contract: "token_0_0",
expr: `transfer("bc1deadbeef", {r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})`,
gasLimit: 10_000n,
}),
});If you prefer not to pass the account at the composeTransaction call-site, it can be passed as an argument to the client.
import {
nativeToken,
createKontorIndexerClient,
http,
signet,
Instruction,
} from "@kontor/kontor-sdk";
export const indexerClient = createKontorIndexerClient({
account: ["taproot-address", "x-only-public-key"],
chain: signet,
transport: http(),
});
const composeOutputs = await indexerClient.composeTransaction({
utxos: ["txid:vout"],
satsPerVByte: 1,
instruction: Instruction.call({
contract: "token_0_0",
expr: `transfer("bc1deadbeef", {r0: 1, r1: 0, r2: 0, r3: 0, sign: plus})`,
gasLimit: 10_000n,
}),
});