A continuación se muestra el enlace oficial de la red theta.
https://docs.thetatoken.org/docs/theta-js-sdk-getting-started#write-to-the-blockchain
Esto debajo de las cosas que he requerido y configurado la red Theta
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);Este es el código que he implementado en Node Js
Quiero hacer una transacción de una cuenta theta a otra cuenta theta usando el paquete thetalab NPM en Node JS.
Para la transacción necesitamos la clave privada del remitente, la clave pública del receptor, la cantidad theta y la cantidad tfuel
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)Recibo este error cuando intento transferir 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)