🔗PhantasmaLink
Introduction
PhantasmaLink is a core component designed for interacting with Phantasma-based wallets. It acts as a foundational block for connecting with wallets.
Class Initialization
PhantasmaLink is a class, and to use it, you must first create an instance of the class.
Vocabulary
Callback: A function called after a successful operation.
onErrorCallback: A function called after a failed operation.
Script: Instructions for PhantasmaChain within a transaction object. See ScriptBuilder for more details.
Nexus: The Phantasma chain in use, either 'mainnet' or 'testnet'.
Payload: Additional data attached to a transaction object.
ProviderHint: Informs PhantasmaLink about the intended wallet for connection.
Functions
login(onLoginCallback, onErrorCallback, providerHint):
Purpose: Initiates login.
Parameters:
providerHint
: Can be 'ecto' or 'poltergeist'.
invokeScript(script, callback):
Executes a read-only script operation on the Phantasma Blockchain.
signTx(nexus, script, payload, callback, onErrorCallback):
Signs a transaction through the wallet.
signTxPow(nexus, script, payload, proofOfWork, callback, onErrorCallback):
Signs a transaction with Proof of Work attached.
getPeer(callback, onErrorCallback):
Retrieves the peer list for the connected network.
signData(data, callback, onErrorCallback):
Signs data through the wallet.
toggleMessageLogging():
Toggles console message logging.
dappID():
Returns the Dapp ID.
sendLinkRequest(request, callback):
Internal use for sending wallet instructions through a socket.
createSocket(), retry(), disconnect(message):
Internal functions for socket management.
ProofOfWork Enumeration
Defines levels of proof of work:
Usage Examples
Provide code snippets and examples demonstrating how to use the various functions of PhantasmaLink.
Login to a wallet
Invoking a Script
Sending a Transaction
Last updated