Questions tagged [nodejs]

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast and scalable network applications.

Filter by
Sorted by
Tagged with
0 votes
1 answer
691 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
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 ...
1 vote
0 answers
13 views

Call a Smart contract function using ethers.js. Trying to request the ABI of the contract with etherscan api and call its method

I'm trying to call mint function using ABI of my test smart contract on goerli - ([https://goerli.etherscan.io/address/0x636c6090348b03a46d73ecc40f005e43662f515d#code]) . I'm sending request using ...
1 vote
1 answer
18 views

Error on WebSocket connection

i want to retrive data from this websocket api, where is my code import { WebSocketServer } from 'ws' let socket = new WebSocketServer('wss://ws.blockchain.info/inv'); socket.on('error', console....
0 votes
1 answer
3k views

Module not found: Error: Can't resolve 'crypto' in '/Users/user/Desktop/esample/react-minting-website/node_modules/eth-lib/lib'

I am building a development web 3 project and can't figure out why I get this error WARNING in src/App.js Line 2:10: 'useWeb3React' is defined but never used no-unused-vars Line 4:8: ...
1 vote
1 answer
10 views

Uniswap API - getAmountsIn function returning incorrect result

I'm quite a rookie in using the uniswap API. What I have is the following. Let's say I want to know how much WETH I need to 100 dydx tokens amountOut = BigInt(100).toString() let result = await ...
1 vote
0 answers
14 views

how to get results from an event

Let's say I have this smart contract code // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "@openzeppelin/contracts@4.4.2/token/ERC721/ERC721.sol"; import "@...
1 vote
0 answers
22 views

Run express api with hardhat and ethersJS

I am trying to call the ethers js functions which in turn call my smart contract using an express API. I created the APIs but I'm unable to run the server and get the response for the API request. I ...
0 votes
1 answer
263 views

Is there a way to specific the block when buy BEP20 token?

To avoid bot, some of fairlaunch and dev make a 99% tax in 2 first block buying after liquidity, it called antibot system. https://bscscan.com/tx/...
0 votes
1 answer
369 views

How to detect if user burned tokens

Looking through the code of ERC20 tokens they have the ability to burn and mint new tokens. I want to write a nodejs program that monitors if a user burns a token and then sends them a new one if ...
0 votes
1 answer
25 views

web3 and some math

There is a transaction that is in pending. In which the user gives 0.02 WBNB (2000000000000000000) to get at least 35460 TM (35460000000000000000000). If he gets less than that the transaction will be ...
0 votes
0 answers
15 views

const provider= new ethers.provider.JsonRpcProvider('https://goerli.infura.io/ws/v3/48e3dcb8dcc3420fa8c765b7c04a75f8'); TypeError:

const provider= new ethers.provider.JsonRpcProvider('https://goerli.infura.io/ws/v3/48e3dcb8dcc3420fa8c765b7c04a75f8'); ^ TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider') I ...
0 votes
2 answers
261 views

Error HH8: There's one or more errors in your config file

MY hardhat.config.js require("@nomicfoundation/hardhat-toolbox"); require("dotenv").config(); require("@nomiclabs/hardhat-etherscan"); const Goerli_RPC_URL = process.env....
1 vote
1 answer
442 views

Why are all ethersjs & web3js calls to BSC network failing?

All calls using "wss://bsc-ws-node.nariox.org:443" and other RPC/WSS endpoints have been failing throughout this week. It just hangs and doesn’t return anything. This is happening in BSC ...
0 votes
1 answer
650 views

EtherscanProvider.getHistory(), got an error;

nodejs.SERVER_ERRORError: missing response (requestBody=null, requestMethod="GET", serverError={"code":"ECONNRESET","path":null,"host":"api....
9 votes
1 answer
1k views

How to use Nodejs/LevelUp to read Blocks from local LevelDb database files (.ldb)?

Here's what I've been able to get going to far. I can open the blockchain database but I can't seem to create a valid blockchain object (nor call the blockchain.getBlock() function successfully). I'...
0 votes
2 answers
429 views

how can i send a transaction in spesific block numbers with web3Js?

I wanna know how to send the transaction in spesific block numbers with web3js ( Yes its for sniping bot ) The purpose is to avoid the tax in 1-3 blocks since liquidity is added For example : New ...
0 votes
1 answer
489 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
1 answer
345 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 ...
12 votes
9 answers
26k views

Solc --version: command not found

I'm trying to use solc with no success. I download solc with npm install solc but when I run solc --version the console output is: command not found. If I list packages npm list I'm able to see ...
2 votes
1 answer
13 views

Getting error while reading the contract data using signer "TypeError: checkProvider(...).call is not a function"

I am creating an instance of singer by passing the pvkey and provider, but after creating the instance of the contract i am not able to interact with it. const signer = new ethers.Wallet(pvKey,apiKey)...
1 vote
2 answers
590 views

Running ethereumjs/testrpc from a Docker container

I'm taking a stab at creating a set-up where I have a Docker container from which I run ethereumjs/testrpc (an Ethereum testing environment) and another Docker container running an Express app. I then ...
0 votes
0 answers
19 views

Error: Returned error: execution reverted / Uniswap Js Bot

I want to work with the price-bot by DAPP University, here is the github repo: https://github.com/dappuniversity/price-bot When I run index.js the following error occures: Error: Returned error: ...
1 vote
1 answer
23 views

BSC: CONNECTION ERROR: Couldn't connect to node

I use this tutorial for run BSC node: https://docs.bnbchain.org/docs/beaconchain/light-client But with web3 I get error: Uncaught (in promise) Error: CONNECTION ERROR: Couldn't connect to node My ...
2 votes
1 answer
408 views

Does it make sense to have a Node.js backend serving json to frontend for dapp?

Currently, the architecture I am looking at is that the smart contract (SC) sits on the ethereum network, but it is a complex and multilevel contract system. Just navigating through the tiers of the ...
0 votes
1 answer
12 views

asking funding while installing solc?

asking for funding while installing solc cant we insatll by skiping it npm install -g solc changed 9 packages in 9s 1 package is looking for funding run npm fund for details
0 votes
2 answers
1k views

Error: Cannot find module 'ethereumjs-wallet'

A truffle test needs ethereumjs-wallet const wallet = require('ethereumjs-wallet'); I tried npm install ethereumjs-wallet and even npm uninstall ethereumjs-wallet npm install --save ethereumjs-...
1 vote
1 answer
2k views

Sending string as address to smartcontract

I have trouble sending an address to a deployed contract, my function looks like this: function addNote(uint _value, address _owner) public { ... } and when I'm sending the parameters: contract....
0 votes
3 answers
3k views

calling smart contract functions from app.js

I deployed a smart contract to ganache network using truffle from account1. The code of smart contract is as follows. pragma solidity ^0.4.0; import "./strings.sol"; import "./safemath.sol"; ...
4 votes
3 answers
1k views

web3.eth.Contract(abi, address) doesn't return contract instance

i'am trying to make a instance of my contract in js using web3, but when I use the function web3.eth.Contract(abi, address) the result is not the expected(I take the ABI from remix). this is the code:...
0 votes
0 answers
12 views

Unable to get the logs when deploying the deploy.js file

my 01_deploy.js const {networks} = require("../hardhat.config") const {developmentchains} = require("../helper-hardhat.config") module.exports = async function ({getNamedAccounts,...
1 vote
1 answer
2k views

[ Web3.js on BSC ]: Returned error: unknown account

Here's the error: index.js:1 Error: Returned error: unknown account I'm getting this error while running this method: nftMintingContract.methods.mint(account, cid).send({from: account}) The ...
0 votes
1 answer
34 views

How to Get All NFTs Owned by an Address on my custom blockchain

on mumbai lets say, i can use the alchemy sdk, where i input the network name and then call the functions easilly, however if the network is testnetwork with a chain id of 1234 and public RPC of : &...
0 votes
1 answer
534 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
23 views

Please help me with this events error with HttpProvider

I have encountered this error while trying to put my oracle online. Please, help!
1 vote
3 answers
38 views

Next Halving BlockChain BlockNumber?

Hello every hope all are good ? I'm asking where can you get the block halving number from a BlockChain ? Is there a way in web3 ? Can i find it in WhitePaper for each BlockChain ? Need i check block ...
0 votes
1 answer
348 views

testrpc --account private key length is invalid even though its my account

I tried to initiate a testrpc account and passing my account with value to test the transactions but when I keyed in my key 0x94fd019eeb92780477b01ce5555513d3755b5193 it says that the key is invalid. ...
1 vote
1 answer
1k views

Smart Contract is being deployed but call does not return contract address after deployment

So I have been trying to deploy a smart contract using nodejs, but when I call the function to deploy, I get no contract address on my console. It's like the send() function never completed its ...
0 votes
1 answer
952 views

how to covert a string to a ether address (20 bytes)?

I have tried to use sha3 but it return error since invalid address. Here is my code. The sha3 returns 32 bytes address. I wonder is there other function that returns 20 bytes . var to_add = web3.sha3(...
1 vote
1 answer
1k views

Getting correct decimals in ethers.io library, using getAmountsOut() ABI

I am using the getAmountsOut() interface to get the current PancakeSwap price of a random BSC token that has 9 decimals in its smart contract, see https://bscscan.com/token/...
0 votes
1 answer
323 views

Solidity solc compiler error on code Remix can compile

I am attempting to compile the following solidity code using solc in NodeJS. pragma solidity ^0.4.11; contract helloWorld { string public message; function constructor() public{ message = "...
0 votes
0 answers
32 views

New Set function doesn't work, ethers js Listening to the event for the contract and displaying from depending on the earlier one

I have a problem with the code that listens to a given contract then depending on whether it was in the same block wants to display the event or not. Unfortunately it does not work and all ...
2 votes
1 answer
468 views

How to listen to smart contract events using nodejs server?

I am currently trying to 'listen events' emitted from my smart contract. I am able to run my scripts created by using the node command and it works as intended, and I want to host it on a server. I ...
1 vote
1 answer
82 views

Ethers How to get token address from uniswap transaction data

I am creating a nodejs script using Ethers that is broadcasting new transactions. I can not find out how to get information about token address. transaction.data is encoded. I am enclosing the below ...
2 votes
2 answers
496 views

NodeJs & Web3 having problem with VS Code IntelliSense (autocomplete)

I'm having issue with autocomplete of Web3 module members in the VS Code. As can be noticed on the screen below web3.eth. not proposing any member of the module. web3 module has been installed over ...
2 votes
1 answer
36 views

process.env.key is showing the actual api key in source code

In my js file I am using: const apikey = process.env.REACT_APP_API_KEY; In the .env file I have: REACT_APP_API_KEY = 123456789 Everything is working fine BUT, when I start (npm run start) and then go ...
1 vote
1 answer
1k views

EthersJS Listening to events with NodeJS Strange Errors

I am trying to listen to blockchain events using ethers on NodeJS. I've looked around for few tutorials and copied the code from one of them. Currently the code i have is: const ethers = require("...
1 vote
1 answer
45 views

getting an error in ethers.js deploy script

My code is const path = require("path") const { ethers } = require("@nomiclabs/hardhat-ethers") const fs = require("fs") require("dotenv").config() module....
1 vote
2 answers
845 views

Get hash transaction by your encode input data

In my application i must follow the use case: I need to record any document hash on the Ropsten (eth testnet) blockchain. The hash is unique and i'm using a mapping in my smart contract to accomplish ...
2 votes
1 answer
2k views

call to smart contract function from express project using web3

I'm trying to create a API fo my smart contract functions like following: router.get('/',function (req,res) { var web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/key'));...

1
2 3 4 5
16