import {PhantasmaKeys, Transaction} from'phantasma-ts';constNexusName="testnet"; // Could also be simnet or mainnetconstChainName="main"; // Since we only have the main chain, it's always main.let payload =Base16.encode("Phantasma-NodeJS"); // This is what going to appear on the explorer and on the wallet.let expiration:Date=newDate(Date.UTC(newDate().getUTCFullYear(),newDate().getUTCMonth(),newDate().getUTCDate(),newDate().getUTCHours() +1,newDate().getUTCMinutes() +10,newDate().getUTCSeconds() +10));let transaction =newTransaction( NexusName,//Nexus Name ChainName,//Chain myScript,//In string format expiration,//Date Object payload //Extra Info to attach to Transaction in Serialized Hex);
Sign a Transaction
Now we need to sign the transaction if we want it to be accepted by the blockchain.
import {PhantasmaKeys} from'phantasma-ts';let wif =""; // WIF of your wallet let keys =PhantasmaKeys.fromWIF(wif);transaction.signWithKeys(keys);let transactionSignedBytes =transaction.toString(true);