Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [nodejs]

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

1
vote
1answer
26 views

Information lost when getting string from byte32 Solidiy smart contract

I have a number as a string which I pass to smart contract function as a parameter. The function takes byte32 as a parameter. Here is the node.js code for executing the contract function: const app =...
0
votes
1answer
7 views

“truffle test” says “assert.rejects” is not a function even it is Node 10

As per the official documentation, assert.rejects was added since Node v10.0.0. Also, the node console confirms that: even though, truffle test throws this error: TypeError: assert.rejects is ...
0
votes
1answer
12 views

What API and framework should I use for ETH based website? [on hold]

I'm looking to build a website which will include a usage of the ETH blockchain, such as letting every user to have a ETH address , allow users to deposit/recieve ETH from the site and so on. What ...
1
vote
1answer
19 views

Detecting nodes by an identity in Ethereum network?

According to this answer: (https://bitcoin.stackexchange.com/a/63657/41513) the following can be definition of a node: "A node is a computer that has a copy of the blockchain (or at least a part ...
0
votes
0answers
10 views

How to call the other function to operat [closed]

const bignum = require('bignum'); web3.eth.getBalance("0xaaaaaaaaaaaaa") .then(function(firstmoney){console.log(firstmoney); return(firstmoney); }); web3.eth.getBalance("0xbbbbbbbbbbbbbb") .then(...
0
votes
1answer
23 views

How can i get my var in Web3, i always get Promise { <pending> }

var gogo =web3.eth.getBalance("0xXXXXXXXXXXXXXX") .then(console.log); console.log(gogo); if (gogo > 123) { console.log('enough.'); } how to run if in this case? Thanks for helping me.
0
votes
1answer
27 views

Send signed transaction from nodejs to private SmartContract using webjs in Quorum network not working

Context I have a quorum network mounted following the example of 7nodes. In node 1 I have deployed a smart contract privately, putting the public key of this ("BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+...
1
vote
2answers
23 views

How to convert a uint to 64 byte hex string using Node.js?

Sir, If my uint is 10,how to convert 10 to '0x000000000000000000000000000000000000000000000000000000000000000a' by using Node.js? and reverse it from '...
0
votes
0answers
12 views

web3 js: Unable to edit a member variable from on receipt anonymous function

I have a web3 js client and trying to deploy a contract. I initially tried with some quick and dirty code and could setup the web3 js client and deploy the contract successfully. However, I'm now ...
1
vote
2answers
25 views

How to setup 'topics' for function getPastLogs ()?

Sir, I want to read the past event log by using getPastLogs(),but I got the whole log.I hope I can filter some log. I find I can setup the 'topics' in getPastLogs(),but it always fails. How ...
0
votes
0answers
13 views

How to get past event log by Node.js?

I want to read past event log. My Node code is: const Web3 = require('web3'); const ethereumUri = 'http://192.168.2.17:8545'; let web3 = new Web3(); web3.setProvider(new web3.providers.HttpProvider(...
0
votes
0answers
17 views

How to pass 'uint' argument to deployed smart contract from web3.js?

In my smart contract, I have a method function addPerson(uint _age, string _name) public payable { // some operation } From my node application, using web3.js library, I am trying to ...
0
votes
1answer
24 views

ethers.js (node.js) call solidity function that is payable

I understand that you can send ethereum to a smart contract, although when you do this with sendTransaction it doesn't seem that you specify a function on the smart contract when you do this. I don't ...
0
votes
2answers
32 views

Blockchain app technical architecture

Let’s say I want to build an app that is not completely decentralized, in fact it serves Restful APIs to the frontend and uses a private ethereum blockchain in the backend to process sensitive data ...
0
votes
2answers
30 views

How to print web3.eth.<function> output on html page?

I am trying to print web3.eth.<function> output on a html page, but I cannot print it. I have followed this answer. My geth-node is running on --rpcport 8545. Let's see simple example to print ...
0
votes
2answers
18 views

Javascirpt 18 decimal number for parameter?

I have created an 18 decimal crypto token in ethereum. When executing smart contract method from javascript for uint256 input parameter, how can I specify the number with 18 zeros? Because javascript ...
0
votes
1answer
45 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
1answer
30 views

Retrieve event args from getPastLogs

When we use web3.eth.getPastLogs it returns topic and data properties together with rest data. Does it possible to retrieve event args parsing just data and topic as filter? Without to make additional ...
0
votes
1answer
12 views

How to code a Raw Txn using web3js?

I have this code which gives JSON error in web3. I tested the connections and reading the contract and that all works. There is something wrong with the "data" key in the JSON. Somehow the addBonus ...
2
votes
2answers
69 views

Unable to install web3 js for windows10

I am trying to install web3 using command npm install --save web3@1.0.0-beta.26 However, it is failing with error : verbose node v8.9.1 verbose npm v4.6.1 error code 128 error Command failed: ...
0
votes
1answer
39 views

How to state private keys when using node.js and ethereum to run a contract?

I have to run node.js to execute smart contracts. My quetsion is about the keys. I have seen this from the docs - 1. Code to sign 2. Code to execute But I am unsure how the two are combined. Could ...
1
vote
1answer
47 views

Syncing events on Database - Dealing with blockchain reorganization

My Dapp relies on live events synchronization on a centralized database. There is always a server side script polling the blockchain for new events, parsing then and do the corresponding operations on ...
0
votes
0answers
19 views

Cannot get Vue.js SSR to work with web3

I am running a vue.js application with a smart contract, the application works without errors on the development server, i can see my contracts - call functions, deploy contracts without an issue. ...
0
votes
0answers
12 views

Is it possible to query ethereum blockchain event logs using nodejs & infura client

I have a contract deployed on Ropsten testnet. From our backend side , I want to use nodejs to query event logs stored in contract. event TokenDelivered(address indexed receiver, uint256 amount); ...
0
votes
1answer
21 views

Should I use Node.js server along with ethereum smart contracts to make Dapps?

I want to make a Dapp using ethereum. So, should I use a Node.js server and a database to store some user's data and store rest of the data on the smart contract that needs to be decentralized or ...
0
votes
0answers
20 views

Is it possible to get return value of contract function called as a transaction from JS? [duplicate]

I’m now developing a simple Dapps using truffle platform. My question is about calls my contract functions from JS. I already know that it is possible to get return value of contract function called ...
0
votes
1answer
34 views

Create accounts on ethereum network using programmatically generated key pairs and addresses

Say I have a node application that has user registration feature. Now when a user registers, using node libraries like crypto I generate a cryptographic key pair(private and public). Then also ...
1
vote
1answer
22 views

Solidity contract state is not updated by signed transaction in nodejs

By signed transaction using web3 in nodejs Transaction hash 0x3c7688326afc83e6524e8c491f203852e34aa0f572d952569b6253e98dbd83a1 Data ...
2
votes
0answers
96 views

ping / pong pattern for infura websocket [closed]

Infura websockets disconnect after an hour of in-activity so they suggest you ping / pong the connection at an interval less then an hour. My problem is I'm new to server-side programming and don't ...
0
votes
0answers
25 views

Unhandled promise rejection(gas limit) when deploying Contract to rinkeby using truffle-hdwallet-provider@0.0.6

I have a problem like this. I am trying to deploy a contract into rinkeby test network using a deploy.js script. This is my deploy.js file. const HDWalletProvider = require("truffle-hdwallet-...
1
vote
0answers
465 views

How do I send html form data as JSON content type with node js? [closed]

I have a smartcontract GovtContract that works fine when I use curl commands, $curl -X POST -H "Content-Type: application/json" localhost:3000/govtcontract/set -d '{"value":"5"}' | jq $curl -X GET -...
0
votes
0answers
75 views

ReferenceError: beforeEach is not defined

my question is about run a js file from cmd and node i have a js code like this : const assert = require('assert'); const ganache = require('ganache-cli'); const Web3 = require('web3'); ...
2
votes
1answer
55 views

how to fix “txHash: undefined” error using web3.js

anyone can fix this?? i always got output "txHash: undefined" var Tx = require('ethereumjs-tx') const Web3 = require('web3') const web3 = newWeb3('https://mainet.infura.io/') const account1 = '...
2
votes
1answer
20 views

multi addresses

how can i send to account2,account3 and account4 in one time transaction var Tx = require('ethereumjs-tx') const Web3 = require('web3') const web3 = new Web3('https://ropsten.infura.io') const ...
0
votes
2answers
31 views

How to access ethereum smart contract functions from server side api calls using ExpressJS?

I have the abi and bytecode of contract functions. Is there a way to access them using api calls only(using web3 module or any other) since i want to integrate them in an android native app and thus ...
1
vote
1answer
65 views

How to calculate optimal gasPrice and gasLimit? [duplicate]

I am using rawTransactions and web3Instance.eth.sendSignedTransaction to deploy and interact with smart-contracts. The problem is that I can't figure out hot to calculate optimal gasPrice & ...
-1
votes
1answer
111 views

ethereum send transaction is not working?

I wrote a sample api to send ethers from one account to another account using rinkeby testnet.It's throwing the following error(I attached screenshot). Please tell me how to resolve that error and why ...
1
vote
1answer
61 views

Solidity mapping multiple items to one user

i'm trying to assign array of items to one user and i want to put address to mapping function and get all items like that: mapping(address => Item[]) public ownerToItems; but there is problem ...
1
vote
0answers
29 views

Initialize Metamask from front-end use of Nodejs

Building a simple ERC-20 Token payment screen for a simple shopping cart. I am having an issue figuring out how to use Metamask to allow others to make secure payments. As we dont have access to other ...
3
votes
1answer
162 views

Does geth --syncmode light download the State Trie?

I'd like to download some recent version of the Ethereum State Trie. I read here that geth --syncmode light downloads the current state. But does that only encompass the most recent blocks or also a ...
1
vote
1answer
84 views

Ipfs.files.add promise throws error [closed]

I'm trying to upload a simple image file to IPFS using ipfs.files.add(). However, I can't seem to figure out why the promise throws an error. Here's the code: $(function() { $(window).load(...
0
votes
1answer
28 views

Is it safe to have a locally running Ethereum node exposing personal RPC API?

I am developing a REST API currently running off a node.js server. The API allows ethereum account creation, making a transaction etc. The API interacts with a locally running ethereum node to ...
1
vote
0answers
25 views

GETH node works on Apache but not on ExpressJs

I had a running GETH node linked to my localhost (hosted with Apache) , I had to migrate the project on a ExpressJs running on port 3000 and now I have Error: CONNECTION ERROR: Couldn't connect to ...
0
votes
0answers
21 views

Get estimated gas and provide gas limit in web3.js [duplicate]

I have written a web3.js implementation in Node.js(server-side). The code below invokes a method of solidity contract that writes some value to blockchain: var Coursetro = CoursetroContract.at('...
0
votes
1answer
51 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
0answers
21 views

Callback for transaction mined

Coursetro.setFile(fileName,"test hash",function(error, result){ if(!error) { console.log("Transaction submitted"); } else{ console.log("Error " + error); } }); I am calling the ...
0
votes
1answer
109 views

Listen to solidity events server-side

I have a following contract: pragma solidity ^0.4.17; contract FileDetail { struct File{ string fileName; string fileHash; } File[] private files; event Uploaded( string ...
1
vote
1answer
153 views

Parity, Web3, Nodejs - Error: Transaction was not mined within 750 seconds, please make sure your transaction was properly sent

I'm using Parity ( "ropsten" test net), Nodejs and web3js to deploy smart contract from my system. Parity is synchronised in test mode, but when I run below code using Nodejs, it gave me a transaction ...
1
vote
0answers
87 views

How to sign transactions using metamask while developing in nodejs?

I am developing an application in nodejs. I need to interact with my smart contract and also want to sign the transaction using metamask as I don't want to manage they keys. I copied the following ...
0
votes
1answer
393 views

Web3.js browser version only

I want to create a simple page to interact with my deployed contract. I don't want to use Node.js. I want to use html + web3.js browser version. I got a link: https://github.com/ethereum/web3.js/tree/...