The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [javascript]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
18 views

Truffle - Get ETH Balance with Web3JS - two different errors

Using Gnache and Truffle unit tests, I have tried two helper routines to get Eth balance for an address. URL to source of the code in comments inline below: const Web3 = require('web3') const ...
0
votes
1answer
12 views

Truffle returning balances from a function

This maybe just a simple Javascript issue, but it's in the context of running under Truffle. I can't seem to access my object variables coming back from my function; thus the tests are failing with ...
0
votes
1answer
24 views

How can a smart contract payable based function returns value against any purchase

I am trying to get a return value from the payable function, the idea is a user must pay the fees and in return, he will get his special code. My JS test code is as follow it('get special code ...
0
votes
0answers
14 views

cloning div container number of deployed child contracts time and put their data inside div container

Sorry for the silly question. I have a div container "product-card" , I want to loop the number of my deployed smart contracts time. every time when I loop I want to clone this div container and ...
0
votes
0answers
22 views

Recursive binary search function (in solidity) not working

This is recursive binary search function in solidity. I run the SortTESTER function to populate an array with values. Then I run the SortUserData function to check values which passes the values to ...
0
votes
0answers
11 views

RSA signature verification: Inputs to Precompile contract

I am trying to verify an RSA signature using Ethereum smart contract. I have some doubts regarding my design. I am using the precompile at address 0X05 to generate s^e mod n, where s is the ...
0
votes
0answers
11 views

How to Convert TransactionHash (SendETH) to Variable?

I have created a function to send Ethereum and it can run inside console.log. With a simple code call a function like this: var sendEth = sendMoney(data).then(hash => { console.log(hash....
0
votes
1answer
20 views

web3js later versions. Bundle, how?

I'm trying to build the frontend of a dApp, but the web3js makes my head hurt. I need to include it in my project, but the latest web3.min.js i can find is this. I want to use 1.2.1, and i understand ...
0
votes
1answer
51 views

Unable to Verify Smart Contract

Currently I want to make a smart contract for verifying documents. However, I couldn't make it works. I have followed the tutorials as shown here (it is for Solidity 0.4.4 and mine is solidity 0.5.0) ...
0
votes
1answer
31 views

Emited Solidity Events not being watched at frontend truffle contract instance

So, I have been reading through A LOT of pages about events in Solidity and how to interact with them on frontend but I am still pretty new to this and it seems like there have been multiple changes, ...
1
vote
1answer
14 views

Geth and JavaScript

I want to deploy a private blockchain using Geth. I am considering using JavaScript to build the backend as I did before (NodeJS) but what about the smart contract? Since it is private is there a way ...
0
votes
1answer
9 views

BrowserSolc not defined

I'm trying to use BrowserSolc in my dApp, but it's just not loading, it seems. I've got browser-solc.min.js in the same folder as index.html, with the following near the top of the page: <script ...
1
vote
2answers
35 views

I Call SmartContract Token ERC20, Why Show Hashing Output ? (Web3 + Metamask + Javascript)

I do not know why with this, even though in the previous version (web3 + Metamask) can issue real data. But now used as hashing (output). I took the example in the code and output below (to get the ...
0
votes
1answer
341 views

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

I am trying to run the follow code that queries an address to track the balance of an ERC 20 Token through the chain's. Eventually I plan on running a big array of account through all the blocks track ...
0
votes
0answers
57 views

Solidity Error: Cannot destructure property `interface` of 'undefined' or 'null'

I've got his error in Solidity when compiling my test file: TypeError: Cannot destructure property interface of 'undefined' or 'null'. I know it is related to my compile.js file, but what is ...
0
votes
1answer
81 views

Upload a full directory to IPFS using ipfs (js-ipfs-http-client)

I want to upload a directory to ipfs on my browser using (js-ipfs-http-client) module. I found this old issue. https://github.com/ipfs/js-ipfs/issues/277 So I decided to use recursive way to add files ...
0
votes
0answers
9 views

build contract interface from contract after offline transaction has been mined

I have created a transaction offline for a contract deploy, to be sent to my server to deploy. Here is my offline created transaction const contract = new ethers.ContractFactory(abi, bin, wallet); ...
0
votes
0answers
18 views

truffle - toUtf8 on Migrations not working

I'm deploying my contracts via migrations and would like to show some info on the console about them just by getting data from these contracts and displaying it. I'm sending a deployed contract to the ...
0
votes
1answer
83 views

Ethers js estimate gas offline?

Looking here in the docs it mentions I need to have the provider attached to estimate gas. But for formatting a transaction offline, I dont have access to the provider. Is there a way to estimate the ...
0
votes
1answer
71 views

Using vanilla javascript with web3 and metamask

I have searched severally on how to use web3 with metamask without nodejs without any success. I want to be able to get an instance of a user's metamask account through web3 and vanilla javascript ...
0
votes
1answer
23 views

Is it possible to instantiate a deployed contract in js using contract address alone? without copying abi data?

Is it possible to instantiate a deployed contract in js(dapp) using contract address alone? without copying abi data?
0
votes
1answer
102 views

'ALERT: Trying to call a function on a non-contract address' Why Do I Keeping This Error?

This is the error from metamask directly: This is the error I get once after I submit the information to IPFS: My Smart Contract: pragma solidity 0.5.3; //Imports for safe math operations import "...
0
votes
1answer
61 views

How Do You Parse Web3 Retuned JSON Objects of Events?

I am using Web3 1.0 to listen to events from a contract like this: tokenContract.events.AddressList({ fromBlock: 6020474, toBlock: 'latest' }, (error, events) => { ...
0
votes
0answers
31 views

How to deploying a contract address on the front-end?

So I'm using web3@0.26.0 to deploy my contract so I can get my contract address from it. And I used it from my backend too and it works. But when I want to implement it on my frontend, I've got an ...
3
votes
1answer
319 views

Getting Tx is not a constructor when executing this program

Here is my code. I am trying to send ether from one account to another. var Tx = require('ethereumjs-tx') const Web3 = require('web3') const web3 = new Web3('https://ropsten.infura.io/v3/...
2
votes
0answers
30 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')...
0
votes
0answers
21 views

Promise Function doesn't wait till transaction end

I am creating a session Contract then get it's public key using event on promise function 'loadSessionContract' but it run before 'creatSessionPromise' finish transaction so I got empty address what I ...
0
votes
1answer
84 views

'types/values length mismatch',

Hey guys I had a problem with my return function here's my smart contract : pragma solidity >=0.4.0 <0.7.0; contract NewHello{ address owner; address newOwner; constructor()public{ ...
0
votes
0answers
24 views

Get the address of a contract without using Remix-ide

I'm studying Ethereum, I need to get the contract address for interact with web3, I can not use Remix-IDE for this since that I installed Kali as an operating system. How I get the contract address ...
0
votes
1answer
574 views

is not a function at HTMLInputElement.onclick error [closed]

I have this error > App.validate is not a function at HTMLInputElement.onclick The code is here : i get error in the last ( >) input type="submit" name="submit" onclick="App.validate()"
0
votes
1answer
34 views

What is the difference between web3 and window.web3

I'm very used to using web3 = new Web3(web3.currentProvider) and I saw here that MetaMask sample code is using window.web3 = new Web3(web3.currentProvider) What's the difference between using and not ...
1
vote
1answer
37 views

Am I hashing the data in the file itself, or just the reference?

I am attempting to create an app where I upload a file to a website and then I submit a hash of that file onto Ethereum. I am unsure whether I am hashing the actual file below or just the reference to ...
0
votes
1answer
42 views

Producing a Hash of a File [closed]

I would like to upload a file to my UI and then produce a hash of it so I could later store it on Ethereum. Here is the code I am using to upload the file: <div> <label for="file input"&...
0
votes
0answers
25 views

web3.eth.getBlock in order

I am a beginner for Javascript & web3(0.20). I am using Metamask for watching allevents, and I need to get timestamp. I use getBlock.timestamp. Due to Javascript, timestamps are not inorder. I ...
1
vote
1answer
164 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
1answer
50 views

Why are integers returning as hex?

I am implementing a simple smart contract in Solidity 0.5.9. One of the functions is called getSummary() which basically returns a summarized version of a vote: function getSummary() public view ...
0
votes
2answers
76 views

how to get contract address after its been mined with web3.js

I have tried to deploy a SmartContract from web3.js node library, I am getting a transaction hash from it but how would I get the contract address after It's been mined by a miner? here is my code ...
1
vote
1answer
32 views

Lib to sign messages using the same version of ECDSA of Ethereum

I want to sign a message using the private key of my physical RSA digital certificate and I want to validate this signature onchain. Does anyone know a lib that can sign messages offchain using the ...
1
vote
0answers
26 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 ...
0
votes
0answers
21 views

address.transfer executes but doesn't make the transfer

I'm using Metamask and web3.js to connect with a donation smart contract. Following is my JavaScript function: function withdraw(){ const contractInstance = connectToContract(); var ...
0
votes
0answers
12 views

How to console.log the value in the React js for the Dapp + truffle project

I am beginner with the ReactJS and Dapp. In my js page I want to get the value after doing some operation on the input value and want to dispay that result. I got the Nan in the front-end screen. ...
0
votes
0answers
31 views

How to handle estimate gas cost error?

I am programming a button for a transaction which shall only appear if the transaction is possible. Therefore, I am using the following code contract.methods.function(parameters) .estimateGas({...},...
0
votes
1answer
76 views

How do I deposit Ether to Smart Contract using Web3.js

So I am creating a web application that interacts with a smart contract that I deployed on the Ropsten TestNet. I am able to withdraw ether from the contract to my Metamask account using a withdraw ...
1
vote
1answer
58 views

MetaMask ethereum.enable() not responding after logout. How to reactivate?

So I found out that after logging out of MetaMask. ethereum.enable() stop working and is not triggering the login prompt window. The only way to reactivate it, is by closing chrome, and start it once ...
0
votes
1answer
35 views

How to compare an address with an address using web3js?

I've been reading and trying but to no avail. I'm trying to compare the current wallet address in MetaMask with the wallet address which owns a certain token via a smart contract method "ownerOf" ...
0
votes
2answers
98 views

Stop listening to / watching a contract (Web3)

Here is what I am trying to do (Web3 1.0): Deploy a contract Wait until Nth confirmation. Then stop getting updates from the contract. My code: var myContract = new web3.eth.Contract(_abi, ...
0
votes
0answers
142 views

truffle-assertions: TypeError: Cannot read property 'filter' of undefined

There is a part of my Solidity code: event elo(address pAddress); function test() external { emit elo(m_Registry); } And a chunk of my test: const truffleAssert = require('truffle-...
0
votes
2answers
92 views

How to wait for balanceOf before I execute a transfer?

Ok, I'm new into JS and web3 and MetaMask. I'm still lost about Promise and async/await after reading them for 5 times! I want to call my smart contract balanceOf method to check if there's enough ...
0
votes
0answers
112 views

Store data on ethereum blockchain from a text file

I have a simple smart contract running over a local Ethereum node. It has two functions: one for sending data and another for retrieving it back. I have a text file and want to send data from it to ...
0
votes
1answer
27 views

How to store and encrypt Keys?

I am developing chrome extension like metamask for the private Chain. I have generated the keys and using localStorage to store the Keys. But I am not sure whether I am going correct or not for ...