🎮
Unity
  • 👋Unity SDK
  • ⚙️Getting Started
    • ⚙️Installation
    • Basic Concepts
  • Features and Functionality
    • 🔗Phantasma Link Client
    • ☁️PhantasmaAPI
    • 📝Scriptbuilder
  • Tutorials and Examples
    • 🖥️Examples
      • Get Account Balances
      • Send a Transaction
      • Get Transaction by Hash
      • Get NFT
      • Get Multiple NFTs
      • Invoke Raw Script
      • Mint an NFT
      • Update an NFT's RAM
      • Burn an NFT
      • Send an NFT
      • Infuse an NFT
      • Mint Tokens
      • Burn Tokens
      • Transfer Tokens
      • Logging in to the Wallet
    • 📹Tutorials
  • Resources
    • 👻About Phantasma
    • 👻Getting Started
    • 🧑‍🤝‍🧑For new Soldiers
    • 👨‍💻For Developers
Powered by GitBook
On this page
  1. Tutorials and Examples
  2. Examples

Invoke Raw Script

This example shows how to call the blockchain directly to get information using the InvokeRawScript() method from the PhantasmaAPI class. A script is created and encoded before being passed to the method.

public void InvokeRawScript()
{
    PhantasmaAPI api = new PhantasmaAPI("https://testnet.phantasma.io/rpc");
    var toAddress = Address.FromText("P2KKEjZK7AbcKZjuZMsWKKgEjNzeGtr2zBiV7qYJHxNXvUa");
    ScriptBuilder sb = new ScriptBuilder();
    var script = sb.
        CallContract("stake", "getStake", toAddress).
        EndScript();
    var scriptEncoded = Base16.Encode(script);
    StartCoroutine(api.InvokeRawScript("main", scriptEncoded, scriptResult =>
    {
        Debug.Log(scriptResult.results.Length);
    }));
}
PreviousGet Multiple NFTsNextMint an NFT

Last updated 2 years ago

🖥️