Below is the official link of theta network
https://docs.thetatoken.org/docs/theta-js-sdk-getting-started#writing-to-the-blockchain
This below things i have require & config the Theta Network
require('isomorphic-fetch'); //In order to get fetch working in Node
const express = require("express");
const BigNumber = require('bignumber.js');
const thetajs = require("@thetalabs/theta-js");
const Wallet = thetajs.Wallet;
const chainId = thetajs.networks.ChainIds.Testnet;
const provider = new thetajs.providers.HttpProvider(chainId);
This is ths code I have implemented in Node Js
I want to do transaction from one theta account to another theta account using thetalab NPM package in Node JS.
For Transaction we need sender private key, receiver public key, theta amount & tfuel amount
var privateKey = "0xf235351c3a8787121162e102dbc4cd79641441a8376dcb0ca46a71b78485c3eb"
const wallet = new Wallet(privateKey);
const address = wallet.address;
const thetaWeiToSend = '0';
const tfuelWeiToSend = '0.1'
const transactionCount = await provider.getTransactionCount(address);
const from = address;
const to = "0x02B74daDAd33040F16eB91d7Aafb1b181a3e7930";
const txData = {
sequence : transactionCount,
from: from,
outputs: [
{
address: to,
thetaWei: thetaWeiToSend,
tfuelWei: tfuelWeiToSend,
}
]
}
const transaction = new thetajs.transactions.SendTransaction(txData, chainId);
console.log('transaction', transaction)
const result = await wallet.sendTransaction(transaction);
console.log('result', result)
I get this error when i am trying to transfer THETA & TFUEL
fund Transfer error TypeError: Cannot read properties of null (reading 'getChainId')
at Wallet.getChainId (D:\Kartik\Theta\node_modules\@thetalabs\theta-js\dist\thetajs.cjs.js:1629:30)
at Wallet.signTransaction (D:\Kartik\Theta\node_modules\@thetalabs\theta-js\dist\thetajs.cjs.js:1648:37)
at Wallet.sendTransaction (D:\Kartik\Theta\node_modules\@thetalabs\theta-js\dist\thetajs.cjs.js:1421:31)
at fundTransfer (D:\Kartik\Theta\thetatransfer.js:49:37)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)