Comment on page

How to Obtain Raw Transaction

Phalcon Block supports various automated blocking methods, allowing project parties to submit Raw Transactions. When the monitoring on the Block system meets the triggering conditions, it will automatically send Pause or other transactions to execute the block.
The following is a JavaScript demo based on the web3 js library.
  1. 1.
    Please install the web3 Javascript library first.
npm install web3
  1. 2.
    JavaScript demo
var Web3 = require('web3');
async function signPauseTransaction(gasLimit,gasPrice,i) {
let contractInstance = new web3Instance.eth.Contract(abi, contractAddr);
let txCount = await web3Instance.eth.getTransactionCount(senderAddr);
const txObj = {
gasLimit: Web3.utils.toHex(gasLimit),
gasPrice: Web3.utils.toHex(gasPrice),
to: contractAddr,
nonce: txCount + i,
data: contractInstance.methods.pause().encodeABI()
}
let tx = await web3Instance.eth.accounts.signTransaction(txObj, privateKey);
console.log(txObj.nonce,":",tx.rawTransaction);
}
const privateKey = ""; //Private key of sender address
const senderAddr = ""; //Sender address
const contractAddr = ""; //Contract address
const gasLimit = 100000; //gasLimit
const gasPrice = 51 * 1e9; //gasPrice
const web3Instance = new Web3("https://binance.llamarpc.com"); //BSC
const abi = [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}];
//Print transactions with consecutive Nonce values.
for (var i=0;i<5;i++)
{
signPauseTransaction(gasLimit,gasPrice,i);
}