🌐
Typescript / Javascript SDK
  • 👋Phantasma - TS
  • 🎆Quick Start
  • Setup
    • 🛠️Setup
  • Shared Methods
    • ☁️PhantasmaAPI
    • 🔗PhantasmaLink
    • 📝ScriptBuilder
      • Create a Script
  • Backend
    • ⚙️Backend
    • 📄Examples
      • Creating a new Address
      • Importing a Wallet
      • Create Script Call
      • Create a Transaction
      • Sign a Transaction
      • Send a Transaction
      • Get a Transaction
      • Invoke a Script
      • Get User Balances
      • Transfer Tokens
      • Decode Transfer Events
      • Get a Block by Height
      • Get data from new Blocks
  • Frontend
    • 🖥️Frontend
    • 📄Examples
      • Connect to the wallet
      • Invoking a Script
      • Sending a transaction
  • Resources
    • 👻Getting Started
    • 👻About Phantasma
    • 🧑‍🤝‍🧑For new Soldiers
    • 👨‍💻For Developers
Powered by GitBook
On this page
  1. Frontend
  2. Examples

Invoking a Script

Get some data from the blockchain

PreviousConnect to the walletNextSending a transaction

Last updated 1 year ago

This is used to query data from the blockchain, it's act's like a get

The arguments or args here should be always inside of an array.

To do it using the PhantasmaAPI check this example

Using Phantasma Link

This example is using the PhantasmaLink

Invoking a Script doesn't need the user to accept anything.

import { PhantasmaLink, Transaction, ScriptBuilder } from "phantasma-ts";

const CHAIN_NAME = "main"; // This is the name of the chain, please don't change it.

let contractName = "mycontract";
let contractMethod = "getMyInfo";
let args = ["arg1", "arg2"]; // this is just a example of arguments.


const sb = new ScriptBuilder();
const myScript = sb.BeginScript()
    .CallContract(contractName, contractMethod, args)
    .EndScript();

Link.invokeScript(myScript, (result) => {
    // Handle the Data returned here.
});
📄
Invoke a Script