addInvokeTransaction
Action for adding a Starknet invoke transaction.
Import
import { addInvokeTransaction } from "starkweb/core";
Usage
index.ts
import { addInvokeTransaction } from "starkweb/core";
import { config } from "./config";
const result = await addInvokeTransaction(config, {
calls: [
{
contractAddress: "0x123...",
entrypoint: "transfer",
calldata: ["0x456...", "1000"],
},
],
});
Parameters
import { type AddInvokeTransactionParameters } from "starkweb/core";
calls
Call[]
Array of contract calls to invoke.
index.ts
import { addInvokeTransaction } from "starkweb/core";
import { config } from "./config";
const result = await addInvokeTransaction(config, {
calls: [
{
contractAddress: "0x123...",
entrypoint: "transfer",
calldata: ["0x456...", "1000"],
},
],
});
chainId (optional)
Hex | undefined
The chain ID to add the transaction to. If not provided, uses the current chain.
index.ts
import { addInvokeTransaction } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
const result = await addInvokeTransaction(config, {
calls: [...],
chainId: mainnet.chain_id,
});
Return Type
import { type AddInvokeTransactionReturnType } from "starkweb/core";
Returns the transaction information including:
chainId
Hex
The chain ID of the network.
transaction_hash
Hex
The hash of the submitted transaction.
Example
example.ts
import { addInvokeTransaction } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
// Add invoke transaction on current chain
const result = await addInvokeTransaction(config, {
calls: [
{
contractAddress: "0x123...",
entrypoint: "transfer",
calldata: ["0x456...", "1000"],
},
],
});
console.log("Transaction hash:", result.transaction_hash);
// Add invoke transaction on specific chain
const mainnetResult = await addInvokeTransaction(config, {
calls: [...],
chainId: mainnet.chain_id,
});
Error
import { type AddInvokeTransactionErrorType } from "starkweb/core";