Questions tagged [javascript]

JavaScript is a dynamic, weakly-typed language used for client-side as well as server-side scripting.

174 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
291 views

Accessing custom JavaScript functions via RPC API on Geth

Geth allows me to define & load my own custom JavaScript functions with --preload flag or require() on Geth console. But is there way to access my functions via RPC interface? Like : curl -H "...
4
votes
1answer
587 views

Ethereum Wallet sync completed and ETH balance went to 0

I ran Ethereum Wallet for the first time on my Macbook Pro and, as it was syncing with TestNet, I selected Develop -> Start Mining. I saw the ETH balance increase steadily to 65 but then, it seemed ...
3
votes
1answer
136 views

Web3JS incorrect return value

When I return a string array with web3 I don't get the original array as expected, but rather I get an array of the same size, with the index off by one. So instead of ["One","Two","Three"] I get ["",...
3
votes
0answers
28 views

Reconstruct sender address from signature

I am using a service that wants me to verify that the data it returns to me is correct before I use it. The service returns something that looks like the following: { "signature": { "v": ...
3
votes
0answers
288 views

How to Catch Connection Issues to Web3 Provider using Web3.js

My node.js script is able to successfully connect to the Web3 provider when both the private key (using truffle-privatekey-provider) and the provider host URL are correct. let privateKey = ..., ...
3
votes
0answers
222 views

Where is the latest MetaMask hello world dapp example?

MetaMask recently added a new permissions check. I'd like a copy-pasteable hello world dapp that includes all best practices and can check the balance of the current user's ERC20 balance for some ...
3
votes
1answer
223 views

error: invalid opcode using modifier

Im getting the following error when trying to run my js test file using truffle: Error: VM Exception while executing eth_call: invalid opcode The js test file is the following: var DebitService = ...
2
votes
0answers
41 views

How shoud I properly initialize DApp and get account address?

I am writing DApp in react, and basically I want to initialize web3, unlock account, and display it. Having web3 in my package.json In the onload I've tried to go following: let Web3 = require('web3')...
2
votes
1answer
50 views

How to retrieve transaction hash value from the Promise object using web3js?

I'm trying to retrieve the transaction hash value after I call my smart contract method. My Promise object looks like below. returnPromise: Promise { "pending" } ​ <state>: "...
2
votes
1answer
78 views

Metamas - Infura problem. Cannot read property 'currentProvider' of undefined

I got a problem. I am using code below to connect to the eth from node.js app. Everything works perfect as long as I have installed MetaMask in my browser. I can be logged in, logged out, all good ...
2
votes
1answer
114 views

Javascript library to use zkSnark circuit

I would like to generate the proofs for zkSnarks on client side and therefore would need a library in javascript that helps to read a circuit and generate proofs. I found one combination here which ...
2
votes
0answers
45 views

How to add function buy to buy button that need array index

I am new to this smart contract and blockchain. I'm trying to do simple selling goods dapps. But i'm stuck at the buy button. I have array for the products. constructor() public { goods[0].owner =...
2
votes
0answers
294 views

Mnemonic and HD Path in Ganache and ethereumjs-tx gives different private key and address

I am having difficulty reproducing the private key and address using the mnemonic and HD path provided by Ganache. Mnemonic weird farm vast surge upper truth answer end radar impact mind jeans HD ...
2
votes
1answer
120 views

Transmit array as first parameter in web3.js

When I develop in solidity combined with web3.js, I face some problem recently. I create a contract code below //setContractDetail(index,bool isConsentItem,uint8[] detailItems) function ...
2
votes
0answers
69 views

Why is getCode so slow? And is there a better way to find out if an address is a contract?

I've been using Web3's getCode call to find out if an address is a contract, but it significantly slows down my application when I add it, even when I try regular ways to speed up queries (running in ...
2
votes
0answers
29 views

Data Scientist wanting to simulate a DAO on private network, unsure of where to begin

My apologies for such a broad question, I couldn't find anything remotely similar to my case and I've got lots of questions - I'll try to narrow the scope down here. Premise: I'm a data science ...
2
votes
0answers
293 views

Customizable key generator for Node JS

I've been looking for a javescript/nodejs package that would take a passphrase as input and generate a public key. But I need it to produce the exact same public key with the exact same passphrase - ...
2
votes
1answer
43 views

Unable to print event without JSONstringify

I am trying to understand the difference among following cases while printing the event: At web3.js listenToEvent: function(){ Contract.deployed().then(function(instance){ instance....
2
votes
2answers
371 views

Using Web3.js, how do I call a function on multiple instances of a contract and then store their results in an array?

Using Web3.js, how do I call a function on multiple instances of a contract and then store their results in an array? I've tried .map and .forEach, but they don't return the objects I expected. I am ...
2
votes
0answers
291 views

Using Truffle with Node JS (MongoDB)

I am trying to use truffle along with a MongoDB database which means that I need multiple ports. For local testing, I have been starting up my RPC, switching the port that the app is listening, and ...
2
votes
0answers
674 views

Swarm web3 upload file from browser

Im following this documentation to implement an application that I pick a file with an input tag <input id="upload" type="file" /> and im tyring to upload using web3 js : document....
2
votes
1answer
139 views

Implementing a transaction fee via direct address and QR code

I was looking through the ethereum javascript api and I was wondering if there is way to implement a custom transaction fee? For an example, if someone send a certain amount of ethereum to another ...
2
votes
0answers
312 views

How to ensure correct ordering when using a for loop in truffle test

I am using truffle (javascript) to test my solidity contracts and want to automatically run my contract functions a large number of times. I can't figure out how to make a for loop work with promises ...
2
votes
1answer
125 views

How was the name “Solidity” chosen?

Academic and historical interest, how was the name "Solidity" conceived by Gavin Wood. Every name has an interesting history, can't find much on Solidity though. It is based on ECMA script standard, ...
1
vote
1answer
27 views

AZTEC validateProof and validateProofByHash sender / signer addresses

The AZTEC Crypto Engine lets you validate proofs and cache them for future re-use, since they are fairly expensive (around 800,000 gas for a 4-note join-split proof before Istanbul, and now about 200,...
1
vote
1answer
33 views

How to print the value of encoded getter functions of contract

UPDATED: Sorry for Inconvenience, I have updated all my question and accept my apology , being naive user. I have encoded getter functions of my contract i.e. ...
1
vote
0answers
22 views

EIP-712 typed signature for arrays

I'm trying to generate a typed signature for an array in JavaScript based on EIP-712 and using eth-sig-util. My problem is that I need to sign an array. It says in the specification to use Type[] or ...
1
vote
1answer
37 views

Could not find declaration module for file 'solc'

I was trying with a simple contract,when I do "node compile.js" in my windows cmd it throws an error.I was using vscode it showing error in const solc = require('solc'),I installed everything ...
1
vote
0answers
76 views

Error: Cross origin null forbidden : ---Problem in downloading Open source contracts from Etherscan.io

UPDATED: I am trying to download source code of open source verified contract from Etherscan.io. Here is my procedure as directed by Ann. 1. Download CSV file of captioned contracts. 2. Write ...
1
vote
0answers
27 views

How to check current status of state variables

I have deployed my contract locally into Ganache (GUI) and then send/call lot of transactions. After these transactions, now I want to check the current status of all state variables. Is there any way/...
1
vote
1answer
21 views

Automatically extracting functions names and parameters from ABI JSON file

I have done some work on captioned subject. For example, I can extract all getter functions (and some constructors as well) of all given smart contracts (in abi json file format). Then i can call (...
1
vote
1answer
355 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 ...
1
vote
0answers
32 views

Can I run a javascript file using geth attach?

I want to automatize one thing. Aftert installing the Quorum nodes, I have to run: docker exec -it quorum_node1_1 geth attach /qdata/dd/geth.ipc Then I am pasting the JS code But I want to ...
1
vote
0answers
141 views

why .call() in Truffle did not return results as expected?

I'm deploying a contract to my private chain and try to call the contract's function. After I got in the geth console and finished deploy contract, I called the function but it doesn't work ...
1
vote
1answer
299 views

Dealing with events in ethers.js

I'm trying to get a better understanding of arbitrary bytes parameters, so I wrote a one-function smart contract that accepts a bytes argument, decodes it, and returns the response. I am having ...
1
vote
1answer
76 views

How do I send multiple transactions from one wallet in Nodejs?

Hi I've been reading around and I came across Web3.js It's not apparent to me how I can send Ether from one wallet to multiple recipients other than in a batch-style request (which inevitably takes a ...
1
vote
0answers
40 views

Unable to retrieve ethereum address from the signed data

I used the web3.eth.accounts.recover method to retrieve the ethereum address but I am getting an error. Here is the code: let v = '0x' + signed_nonce.slice(130,134); let r = signed_nonce.slice(0,...
1
vote
0answers
234 views

web3 - promise doesn't work as expected

I'm trying to write a code that reads variable, adds 1, sends update call, waits until the transaction is done and then reads the variable again. Console shows that the transaction is complete, but ...
1
vote
0answers
80 views

Return value from a smart contract function appearing for few seconds and then disappears

I developed a Dapp in which I am adding attributes to an entity, and finally I have a function to query some of the information about that entity, when I am clicking on the button to execute the ...
1
vote
1answer
25 views

Accessing the Ethereum State Variables using web3js (Java Script)

I'm trying to run the below code to get the state variables using the getIdBytes method of the Smart Contract, and assign it to a java script array variable, but it doesn't seem to work. All I can ...
1
vote
0answers
58 views

is not contract address during truffle test

I have a stupid smart contract like this: pragma solidity ^0.4.24; contract ProdottoFactory { function foo() view returns(string nome){ return "foo"; } } And I want to test it ...
1
vote
2answers
172 views

How to dynamically load contracts data with their ABI from etherscan API?

Im wanting to pull data from a smart contract I've loaded via user address and etherscan API for the ABI. But how would I go about programmatically adding all the functions from the ABI into my ...
1
vote
0answers
140 views

How to get gasPrice from API and use it in truffle.js mainnet network?

I'm fairly new to javascript and I'm trying to automate pulling the gas price from an api and using it into the truffle.js used to execute via truffle. Basically, I can pull the gasprice via the API ...
1
vote
1answer
241 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 ...
1
vote
2answers
222 views

How to stop listening to all events of contract

I am using the JavaScript API in my truffle tests to get the events from the contract: https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-allevents const allEvents = instance....
1
vote
0answers
35 views

Executing two contracts on one button click

I tried executing two contract when I press a button. Everything seems alright until the transaction page appears and I have 3 contract transactions, the first contract executed once and the second ...
1
vote
0answers
30 views

Optimizing web site to interact with ethereum Network Main net

I have been testing my dapp over rinkeby network, after about 2 months it began to be very slow when asking information to the blockchain. so we decide to change to ropsten network, where we saw it ...
1
vote
0answers
69 views

encodeABI() throws Uncaught (in promise) Error

I am trying to use encodeABI() on one of my contract methods like this: signTx = async () => { ... const response = await contract.methods.recoverAddr(fixed_msg_sha, v_decimal, r, s)....
1
vote
0answers
243 views

Loading Script Geth puppeth

I failed to load a script into a private blockchain setup using puppeth. I have used puppeth to configure a private blockchain (PoA) with a few sealers on different vms. Could someone help? I now ...
1
vote
0answers
81 views

Watch Events with same Name but different params

using web3@0.0.xx is there a way to get Events overloaded (with the same name, but different params) ? I found contract.Transfer[‘address,address,uint256,address,bytes’]({ fromBlock: 0, ...