Questions tagged [nodejs]
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast and scalable network applications.
760
questions
2
votes
2
answers
2k
views
window is not defined when used with next.js
I am trying to write a React-next.js app. I have the following file that exports an instance of Web3 by passing in window.ethereum to the constructor.
import Web3 from 'web3';
const web3 = new Web3(...
0
votes
1
answer
43
views
Error: /api/v0/object has been removed, use /api/v0/dag instead
I am using ipfs for image upload in my form it was working fine but from few days back it's giving me the error.
the following is my code.
uploaddoc: function(){
const reader = new FileReader();
...
0
votes
1
answer
200
views
Problem with eth.sendRawTransaction in geth console
Im trying to use the following code with nodejs to create a raw transaction:
const ethTx = require('ethereumjs-tx').Transaction;
const txParams = {
nonce: '0x0',
gasPrice: '0x3B9ACA00',
...
0
votes
0
answers
253
views
Uncaught SyntaxError: Unexpected token x in JSON at position 1
While running this snippet below, getting error: Uncaught SyntaxError SyntaxError: Unexpected token x in JSON at position 1
const {ethers,Contract,utils}=require("ethers")
const ERC20 = ...
1
vote
1
answer
745
views
why vs code not recognizing the node version
when I install a "truffle for vs code" extension in vs code and try to create a new solidity project then nodejs version is not recognized but I have installed nodejs's correct version.
1
vote
3
answers
431
views
Slippage in ethers.js
Very new to this and can not really find anything on this, these two numbers 50 and 10000 do they = the same slippage?
Is this auto slippage?
I want 20% slippage for a launch today.
async function ...
1
vote
1
answer
2k
views
How to send BNB from my wallet to another wallet using web3?
I am sending BNB from one to another wallet but I a getting an error when I execute my code while I have 0.009 BNB in my wallet :
Error: Returned error: insufficient funds for gas * price + value
Here ...
0
votes
1
answer
907
views
swapTokensForExactETH, execution reverted: null
I m trying to estimate gas for a swapTokensForExactETH transaction with pancakeswap contract (similar to uniswap one)
When i do, i get the following error: Error: Returned error: execution reverted ...
0
votes
1
answer
528
views
Is there a multi-call equivalent for calls that aren't made to a smart contract?
I have an array with a bunch of events. I get the block number from these events but I also need the block.timestamp which isnt returned in the event object, its returned by getting the block. So I am ...
0
votes
1
answer
487
views
about Swap tokens on Uniswap using a smart contract
I would like to build a bot (using VS code) that swaps ETH for other tokens and swap other tokens for ETH using a smart contract.I read the code in this article:https://cryptomarketpool.com/how-to-...
0
votes
0
answers
104
views
Getting "Expected private key to be an Uint8Array with length 32" when running a transfer function on ropsten testnet through my terminal
i am trying to send a transaction but it throws an error.
MY CODE:
var Tx = require('ethereumjs-tx').Transaction
const Web3 = require('web3')
const web3 = new Web3('https://ropsten.infura.io/v3/...
0
votes
0
answers
151
views
openseaJs SDK error TypeError: Cannot read properties of undefined (reading 'target')
I am receiving this error from openseaJs while calling fullfillorder
TypeError: Cannot read properties of undefined (reading 'target')
at computeOrderParams (/…/node_modules/opensea-js/src/seaport.ts:...
0
votes
0
answers
67
views
Returned error: replacement transaction underpriced and Returned error: exceeds block gas limit
I'm trying to send a Web3JS transaction for a SmartContract (BSC) but it always returns Returned error: replacement transaction underpriced and if I increase the Gas it generates Returned error: ...
0
votes
0
answers
189
views
Error by npm run deploy_contract
am having an issue!
I am getting a catch error ( catch ERROR: ERROR STATUS: 403) when I ran "npm run deploy_contract"
10k-collection-video@2.0.0 deploy_contract
node utils/nftport/...
0
votes
0
answers
23
views
Linking OpenSea live-price from an auction to personal website
I want to auction on OpenSea.
I am building a custom website to promote my NFT. On it, I have currently a listing price, but I would like to link a live-price via OS API. Is there a tutorial / simple ...
1
vote
1
answer
852
views
UniswapV3 price calculated using sqrtPriceX96 is wrong
I'm calculating a UniswapV3 pool's token0 price in Node.js. Using UniswapV3 SDK gives correct result, but manual calculation isn't.
From the docs -
sqrtPriceX96 = sqrt(price) * 2 ** 96
# divide both ...
0
votes
2
answers
410
views
Web3 make NodeJS wait until a promise gets resolved inside a subscription?
I have the following code:
import Web3 from 'web3';
function waitForFunds() {
let web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));
return new Promise((resolve, ...
0
votes
0
answers
557
views
How to programmatically swap tokens using a smart contract with NodeJS and Solidity
I would like to build a bot (using VS code) that swaps ETH for other tokens and swap other tokens for ETH using a smart contract. I have used Remix IDE but I get errors that I can't fix. For example, &...
0
votes
0
answers
900
views
Uncaught TypeError: Cannot read properties of undefined
I keep getting this error message in my browser inspect element console.
2shortenAddress.js:1
Uncaught TypeError: Cannot read properties of undefined (reading 'slice')
at shortenAddress (...
0
votes
1
answer
689
views
How to confirm a transaction in backend in behavior of the user?
I am developing an application where the front-end does not talk directly to the blockchain. Back-end does that instead, due to some proccesses that can only be done in the back-end (file manipulation,...
0
votes
1
answer
135
views
I am following the Wormhole SDK to bridge from Fantom to Terra. and while I try to get signedVAA I got < ReferenceError: self is not defined>
const WORMHOLE_RPC_HOSTS = 'https://wormhole-v2-testnet-api.certus.one'
const { signedVAA } = await getSignedVAA(
WORMHOLE_RPC_HOSTS,
CHAIN_ID_TERRA,
emitterAddress,
...
0
votes
1
answer
503
views
ReferenceError: Process is not defined
Here is the script in my deploy.js:
const main = async () => {
// We get the contract to deploy
const Transactions = await hre.ethers.getContractFactory("Transactions");
const ...
0
votes
1
answer
101
views
ReferenceError: greeter is not defined
Here is the script in my deploy.js:
const main = async () => {
// We get the contract to deploy
const Transactions = await hre.ethers.getContractFactory("Transactions");
const ...
1
vote
1
answer
522
views
I keep getting this error while trying to compile my contract trough the HardHat feature
Here is the script in my deploy.js:
const main = async () => {
// We get the contract to deploy
const Transactions = await hre.ethers.getContractFactory("Transactions");
const ...
0
votes
1
answer
34
views
What Database (or maybe the whole stack) should I use for a webapp?
I am thinking of making a webapp where I have to save some private data and other data that could be public. For simplicity let's say it's a quizzes page but it logs in with Metamask.
We are going to ...
0
votes
1
answer
1k
views
error: Invalid JSON RPC response: "" when trying to transfer testnet token
I am trying to transfer testnet tokens using Node.js, Web3.js, Ethers, and Alchemy but I am receiving Invalid JSON RPC response: "" whenever I deploy my code to Railway. Is this an issue of ...
0
votes
1
answer
435
views
BIP32 Extended Public Key Generate Ethereum Address
BIP32 Extended Public Key How can I generate an address with node js?
Is something like this possible
0
votes
1
answer
139
views
Sending big values to wallet
I want to send big value (10000000) for example to other wallet but i have error like this:
UnhandledPromiseRejectionWarning: Error: Error: [number-to-bn] while converting number 3.0244e+22 to BN.js ...
0
votes
0
answers
207
views
Invalid Arrayify Value when querying Uniswap v3 Quoter contract
Does anyone know why my code for passing an array of pool addresses into the QuoterV2 quoteExactInput function is returning an 'invalid arrayify value' error?
async function main() {
var amt = ...
0
votes
1
answer
665
views
i have problem installing truffle ,when i try npm truffle -v i get this error message
truffle : File C:\Users\hp\AppData\Roaming\npm\truffle.ps1 cannot be loaded. The file C:\Users\hp\AppData\Roaming\npm\truffle.ps1 is not digitally signed. You cannot run this script on the current ...
1
vote
0
answers
150
views
Block capacity - Hyperledger Besu
Good afternoon,
I am trying to perform a transaction capacity test on my network with Hyperledger Besu with 4 validator nodes and a time per block of 4seconds.
I have created a script with NodeJS that ...
0
votes
0
answers
33
views
Error while sending transaction via node.js
I have error while I'm sending a transaction from node.js (influra) like this.
Error: Invalid JSON RPC response: "invalid JWT\n"
Why?
0
votes
0
answers
96
views
BSC bot stops buying tokens after some time
I made a mostly profitable bot using node.js buying and selling shitcoins on BSC. However, sometimes the bot just stops buying.
I use web3 to find relevant mined transactions (this part always works) ...
0
votes
0
answers
109
views
Can we sign and approve a transaction or call a function from our NodeJS Backend without involving metamask?
I am creating an NFT marketplace where I need to accept fiat payments. I am using stripe and after confirmation of fiat payment, I want to call the transfer function of my smart contract from NodeJs ...
2
votes
1
answer
463
views
How to send Uniswap V3: Positions NFT to another wallet using Node.js
I have the private key for the wallet. How can I send Uniswap V3: Positions NFT (UNI-V3-POS) from this wallet to another wallet using Node.js and ethers.js for example?
Token contract address: ...
0
votes
0
answers
189
views
IPFS .cat() method doesn’t return the content
I work with JavaScript and Browserify tool in Windows 10. With Browserify, One can require NodeJS modules on browser side. I required ipfs module for my JavaScript code in a .js file then browserfied ...
3
votes
1
answer
2k
views
How to get connected wallet address in node.js server side
I couldn't find a way to obtain accounts the user connected in my website in my node.js web server.
This is what I've tried
const express = require('express');
const Web3 = require('web3');
const web3 ...
0
votes
0
answers
48
views
How to send my content to a global IPFS node?
To use IPFS in NodeJS, I require ipfs module. To connect a IPFS node I try:
const IPFS=require("ipfs");
const node= await IPFS.create();
After that, When I run NodeJS in PowerShell, The ...
1
vote
3
answers
2k
views
How to use web3.js in node.js web server
I am wondering how to use web3.js in my node.js web server in the correct way. I have a button in the homepage where allows users to connect to their wallet, and it is done in my front end. After ...
0
votes
2
answers
169
views
Web3.js Script exits while listening to CreatedPairs
I am trying to create a simple script to test the event listening functionality of Web3.js CreatedPairs. However, my script runs through the code once and then exits instead of continuing to listen ...
0
votes
1
answer
400
views
Create blockchain from scratch with smart contract support
I'm looking to create a private blockchain from scratch for an academic project with its own cryptocurrency (looking to make a fiat-based stablecoin).
I managed to code a simple infrastructure on my ...
0
votes
0
answers
130
views
Any way to change the subscription?
I'm working with "web3.eth.subscribe" but when I've been running the script for 20-40 minutes, the script stops automatically. I think it's because it does an unsubscribe, that is, the ...
0
votes
1
answer
341
views
How can I calculate gas fee when swapping tokens?
This is my code.
const amountIn = ethers.utils.parseUnits('0.1', 'ether'); //ether is the measurement, not the coin
const amounts = await router.getAmountsOut(amountIn, [buyToken, sellToken]);
const ...
0
votes
1
answer
39
views
Intiate web3 object in server.js or in each controller
I was creating a dApp on ethereum. The backend I am using is nodejs. While creating the server, I faced a confusion.
Should I create a web3 instance on the server or on each controller?
I cannot find ...
0
votes
0
answers
651
views
How to modify my sniper bot (or front-run bot) to bring the profit?
The sniper bot will scan the mempool and find addliquidity method and then buy the token.
The sniper bot can work but it always loss money because the following reason:
Maybe the token have the very ...
0
votes
1
answer
456
views
How's Liquidity Pool ID obtained from?
When programming Yield Farming, particularly in JS, MasterChefV3 requires an ID of liquidity pool, in order to make a deposit(...) into it.
Where or how does one get a liquidity pool ID? it's not ...
1
vote
1
answer
428
views
Code to convert crypto wallet passphrase to 32 byte private key
What function in nodejs, or using the relevant crypto packages (web3, ethers, cryptojs, etc) can do this?
For example, need a function within node that can turn something that looks like this: "...
3
votes
2
answers
16k
views
Module not found: Error: Can't resolve 'stream' in React project including web3
When I include web3 in a project I am getting node compile errors like this...
ERROR in ./node_modules/cipher-base/index.js 3:16-43
Module not found: Error: Can't resolve 'stream' in '/Users/xxx/dev/...
0
votes
0
answers
332
views
Retrieving a web3 instance from nextJs
In my nextJS application, I am trying to create a lambda function that returns web3 object:
import Web3 from "web3";
const web3 = () => {
if (typeof window !== "undefined" &...
0
votes
0
answers
143
views
buildTransaction for swapExactTokensForETHSupportingFeeOnTransferTokens
I'm a beginner with Web3 programming. Trying to understand how all it all works.
Managed to get some nodejs code working for buying tokens but when trying to create a script that sells tokens I get an ...