Before Invoking a Script, learn how to create one,here.
Also you need to know how to setup the PhantasmaAPI, to be able to call it Check it Here.
import { PhantasmaAPI, ScriptBuilder } from"phantasma-ts";constCHAIN_NAME="main"; // This is the name of the chain, please don't change it.const NETWORK_API_URL = "https://testnet.phantasma.io/rpc"; // for mainnet this should be https://pharpc1.phantasma.io/rpc
const NETWORK_PEER_URL = undefined; // this the peers URL to get the list of peers, if not provided it will use the default one "https://peers.phantasma.io/"
constNEXUS_NAME="testnet"; // For mainnet use this "mainnet"constAPI=newPhantasmaAPI(NETWORK_API_URL,NETWORK_PEER_URL,NEXUS_NAME);letRPC=newPhantasmaAPI('https://testnet.phantasma.io/rpc',undefined,'testnet');asyncfunctionGetMasterCount(){let sb =newScriptBuilder();let script = sb.CallContract("stake","GetMasterCount", []) .EndScript();let myScript =sb.str;let txResult =awaitRPC.invokeRawScript(myScript);// this will return the data in a VMObject in Base16, you need to decode it.return txResult;}