Read Only Calls
Basic read-only call
import { fetchCallReadOnlyFunction, type ClarityValue, cvToString } from '@stacks/transactions';
const contractAddress = 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4';
const contractName = 'sbtc-token';
const functionName = 'get-total-supply';
const response: ClarityValue = await fetchCallReadOnlyFunction({
contractName,
contractAddress,
functionName,
functionArgs: [],
senderAddress: 'SP2W7056R74EXF6GMGYXEKP6T5NT0FPQET74HXSCS',
});
console.log(response);
// { type: 'ok',
// value: { type: 'uint', value: 452551588021n }
// }
console.log(cvToString(response))
// (ok u452551588021)Passing function arguments
Handling response types
Using custom network
Last updated
Was this helpful?