🌐
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

Sending a transaction

PreviousInvoking a Script

Last updated 1 year ago

After sending the transaction, you might receive a popup on the wallet that you're using to allow the transaction to go through.

Need help understanding how to create a Script ( a call to a blockchain to execute a chain of commands ) ? Check the following page.

Using Phantasma Link

The signTx is the method that will call the Wallet for the user to accept or reject the transaction.

import { PhantasmaLink, ScriptBuilder, Address, Base16 } from 'phantasma-ts';

let gasPrice = 100000;
let gasLimit = 210000;

// Link variable is from the Connect to the Wallet example.

if (!Link.account) {
    // Account not logged in.
    return;
}

const from = Address.FromText(String(Link.account.address));

const payload = Base16.encode('Example.' + contractName);
const sb = new ScriptBuilder();
const myScript = sb.AllowGas(from, Address.Null, gasPrice, gasLimit)
    .CallContract(contractName, contractMethod, args)
    .SpendGas(from)
    .EndScript();

Link.signTx(myScript, payload, async function (txHash) {
    console.log(txHash);
function () {
    // Error On Sending the transaction.
});
📄
Create a Script