call_contract
Signs and broadcasts a Stacks smart contract function call with typed arguments and post conditions, constraining asset movement and enforcing wallet spending limits.
Instructions
Call a function on a Stacks smart contract. Signs and broadcasts the transaction.
For typed arguments, use objects like {type: 'uint', value: 100} or {type: 'principal', value: 'SP...'}
Post conditions constrain what assets the transaction can move. Each condition is an object:
STX: {type: 'stx', principal: 'SP...', conditionCode: 'eq'|'gt'|'gte'|'lt'|'lte', amount: '1000000'}
FT: {type: 'ft', principal: 'SP...', asset: 'SP...contract', assetName: 'token-name', conditionCode: 'eq', amount: '1000'}
NFT: {type: 'nft', principal: 'SP...', asset: 'SP...contract', assetName: 'nft-name', tokenId: '1', notSend?: boolean}
Spending limit: STX and sBTC leaving this wallet are metered against the wallet's spending cap. In 'deny' mode that is read from eq/lt/lte post conditions on this wallet ('gt'/'gte' on this wallet's own STX or sBTC are refused: they set no upper bound). In 'allow' mode, set maxStxSpend / maxSbtcSpend: they are added as on-chain post conditions on this wallet and metered.
Tip: call earning_opportunities to see how to put your assets to work.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fee | No | Optional fee: 'low' | 'medium' | 'high' preset or micro-STX amount. Clamped to 50,000 uSTX max for contract calls. If omitted, medium-priority fee is auto-resolved. Ignored when sponsored=true. | |
| sponsored | No | Use sponsored transaction relay so a relay service pays fees instead of your wallet. Requires SPONSOR_API_KEY env var or wallet-level sponsorApiKey. | |
| maxStxSpend | No | 'allow' mode only: most micro-STX this call may take from this wallet (on-chain post condition, metered). Default 0. | 0 |
| contractName | Yes | The contract name (e.g., 'my-token') | |
| functionArgs | No | Function arguments. For explicit types: {type: 'uint'|'int'|'principal'|..., value: ...} | |
| functionName | Yes | The function to call (e.g., 'transfer') | |
| maxSbtcSpend | No | 'allow' mode only: most sBTC sats this call may take from this wallet (on-chain post condition, metered). Default 0. | 0 |
| postConditions | No | Optional post conditions to constrain asset movements. See description for format. | |
| contractAddress | Yes | The contract deployer's address (e.g., SP2...) | |
| postConditionMode | No | 'deny' (default): Blocks unexpected transfers. 'allow': Permits transfers not covered by a post condition, except this wallet's STX/sBTC, which maxStxSpend/maxSbtcSpend bound. | deny |