Contract Calls
Basic contract call
import {
makeContractCall,
broadcastTransaction,
} from '@stacks/transactions';
async function callContract() {
const txOptions = {
contractAddress: 'SPQR8VS42ZCYH73W1T495CDCESYD360Y1D2N0AMJ',
contractName: 'counter',
functionName: 'increment',
functionArgs: [],
senderKey: 'your-private-key',
network: 'mainnet',
};
const transaction = await makeContractCall(txOptions);
const broadcastResponse = await broadcastTransaction({ transaction });
console.log('Transaction ID:', broadcastResponse.txid);
}Passing function arguments
Complex argument types
Handling contract responses
Last updated
Was this helpful?