stx_callContract
Wrapper method for `stx_signTransaction` that calls a Stacks contract
Method name
stx_callContract
Parameters
Parameter
Description
Required
Type
contract
Fully qualified contract identifier, including Stacks address and contract name.
✅
string
functionName
Name of the function to call.
✅
string
functionArgs
Arguments to pass to the contract function, encoded as strings.
✅
string[]
Example request
try {
// Call a read-only contract function
const response = await window.LeatherProvider.request("stx_callContract", {
contract: "SP3FBR2AGK5X3Y5D0X6MYB6Z3R9Y3WNRJY9ZTV8PV.my-contract",
functionName: "get-balance",
functionArgs: [],
});
console.log("Response:", response);
} catch (error) {
console.log("Request error:", error.error.code, error.error.message);
}
Example response
{
"jsonrpc": "2.0",
"id": "d5e8a7bf-2bc6-4e5e-9c4d-8a6e1d2f99eb",
"result": {
"txid": "0x9a12b3c4d5e6f7890ab1c2d3e4f567890abcdef1234567890abcdef123456789",
"transaction": "0xe3a1b2c3..."
}
}
Last updated