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
1answer
31 views

I'm getting “Cross-Origin Request Blocked” error

I'm getting this error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8545/. (Reason: CORS request did not succeed). I'm aware ...
0
votes
1answer
21 views

Interact with smart contract without metamask

I'm writing an ethereum application that I want to use for an IoT demonstrator. I want to use MQTT to subscribe to an topic and as soon as a signal is transmitted to that topic I want to write ...
0
votes
1answer
16 views

Read message of require statement in app.js

In my App.js I have called the smart contract function and the require statement in the function is not satisfied, so how do I get the message of that require statement in my App.js?
1
vote
1answer
22 views

Value of emitted events in App.js

Actually in my App.js I have called my contract function like this: [ this.state.swapcontract.methods.sendFunds(address).send({ from: this.state.account , value:amount}) ] The function is called ...
0
votes
0answers
23 views

How to get return value from a contract on JavaScript? [duplicate]

I am making a contract with a front-end made with JS, I studied myself how to make it work calling the functions with or without variables. But I don't know how to get the return value. I would ...
0
votes
1answer
19 views

Executing an contract via code and without metamask / link an account to JS code to automatically wirte on Ethereum

I'm trying to get my JS-code to call a smart contract on Ethereum (kovan testnet) that will write something on the blockchain and therefore needs ether (actually gas). I called a view function which ...
1
vote
0answers
29 views

listening for solidity event with Javascript

I am attempting to make a simple guessing game. Game rules: Player 1 initiates the game with a contract address, upper bound, lower bound and answer. Player 2 has 10 guesses to guess the answer or ...
1
vote
0answers
18 views

Why won't my HTML file run/import my JS file?

My app.js file runs a node.js HTML server using nodemon app.js. I'm using fs.readFile to run index.html for the front-end. index.html file imports main.js using <script type="text/javascript" src="/...
1
vote
0answers
23 views

when iam runing npm run dev it showing me this error, how to solve this [closed]

[![shiva@shiva-VirtualBox:~/sta$ npm run dev StarNotary@1.0.0 dev /home/shiva/sta lite-server ** browser-sync config ** { injectChanges: false, files: [ './**/*.{html,htm,css,js}' ], ...
2
votes
2answers
34 views

How to decode a transaction to verify its signature in Javascript?

I noticed that it's possible to sign a transaction with a wrong private key. I took the following example found at https://github.com/ethereumjs/ethereumjs-tx const EthereumTx = require('ethereumjs-...
1
vote
0answers
20 views

ipfs with ethereum

Module not found: Can't resolve 'ipfs-api' in 'C:\Users.......\src' I have used this code //using the infura.io node, otherwise ipfs requires you to run a //daemon on your own computer/server. const ...
1
vote
0answers
29 views

UnhandledPromiseRejectionWarning TypeError when deploying multiple contracts (>200) at the same time

I get the following error: (node:6540) UnhandledPromiseRejectionWarning: TypeError: this.removeListener is not a function at Object.receipt (c:\Users\pruto\OneDrive\Documents\Smart contracts\...
2
votes
0answers
34 views

Confidential data encryption on blockchain

I already built a supply chain that is able to collect product information on Ethereum. Now, that data can be confidential, but I still want to do Matrix calculations on it. I came across homomorphic ...
2
votes
1answer
29 views

What is the easier way (no libraries, no 100KB of JavaScript) to read value from the blockchain?

I'm working on an open-source project. I'm hesitant to include web3.js with all the code. I just want to read a single value from the Ethereum blockchain. That is why my requirement is to avoid ...
0
votes
1answer
17 views

Different block information for the same block number at different times

On web3.eth.subscribe('newBlockHeaders') I get notification and trying to get last block via saved block number earlier. It was happen with 9559839 block number on mainnet. First, I was get data with ...
1
vote
1answer
17 views

Unlocking the ethereum created in azure in azure shell

I have created an ethereum account using ethereum proof of authority in azure and metamask I have been trying to unlock my ethereum account to use it with my website i entered details like this in ...
0
votes
0answers
13 views

Calling decodelog with dynamic number of arguments

the number of input arguments is dynamic, how can I decode many log by one? this is all i tried to do for (let n = 0; n <= receipt.logs.length-1; n++) { if(event.code === receipt.logs[n]....
0
votes
1answer
25 views

How can I extract a wallet address from event data?

I have a contract that returns event data including the sender's address: event Result( address indexed _walletAddress, string _name, uint256 _amount ) And in my Node.js app I try to ...
0
votes
1answer
23 views

How do I prompt metamask to open?

I'm using react and javascript. For whatever reason, I've tried a few methods and it doesn't seem to be opening metamask. await window.ethereum.enable(); and window.web3 = new Web3(web3....
0
votes
0answers
26 views

Access to smart contract's value in Browser

My Truffle project is this contract that just shows Yerevan is love: pragma solidity ^0.5.12; contract TEST{ string public note="Yerevan is love"; function rep() public view returns(string memory){ ...
0
votes
0answers
8 views

How to update Data on UI

I have a UI thats connected to metamask The UI updates all the Info now on address change and when metamask is enabled How can i make my UI update every second? so it always shows accurate stats on ...
0
votes
1answer
33 views

Access to smart contract's value in Node-js

I am working on a simple Truffle project that just shows "Yerevan is love". My contract code: pragma solidity ^0.5.12; contract TEST{ bytes note="Yerevan is love"; function fname() public view ...
0
votes
1answer
28 views

I cannot see Ethereum accounts in Browser

There are 10 Ethereum accounts in Ganache. I work on a Truffle project. Whenever i run the following codes in Nodejs: var Web3 = require('web3'); var web3 = new Web3("ws://localhost:8545"); var acc= ...
0
votes
0answers
21 views

XMLHttpRequest() does not work probably in a Truffle project

I want to connect to my smart contract in a Truffle project and get some information from it. The smart contract's name is "TEST". The follow is my app.js code that should communicate with my smart ...
1
vote
1answer
17 views

Problem with contracts being deployed multiple times in Node.JS backend

I have a Javascript frontend that passes records in a JSON to the backend via Express to be deployed to the blockchain (currently using Rinkeby) with truffle-hdwallet-provider. This appears to work ...
0
votes
0answers
16 views

How to send a value back to html from node.js using express and truffle

I am running truffle code with Node.JS in the backend to deploy contracts. Using the Express Library, I can interact with the Node backend. Here is the code for the HTML page: <form id="myForm" ...
0
votes
1answer
21 views

Testing library functions with Javascript & Truffle

I'm trying to test functions of a library with Truffle. But they don't seem to be available. The library is named Commons and I include it as I would include a contract: var Commons = artifacts....
0
votes
1answer
59 views

Problem with running truffle code with node.js

I am trying to run truffle code with Node.JS in the backend to deploy contracts. I want to be able to do this interactively and I am intending to use the Express Library to interact with the Node ...
0
votes
1answer
28 views

How to convert to 8 digits in etherum

I have a token that has 8 digits, so the output is 4762575931 instead of 47.62575.. How can i change this so this works on UI and for metamask input? I know there is the function to wei but this is ...
1
vote
1answer
33 views

Logic help needed, how to transfer funds to the address who placed bets on winning team?

This is a betting application and right now -> if I place bets on HOME, the amount gets stored but I want to transfer the amount only to the address who placed bets on winning team. I have developed ...
0
votes
0answers
20 views

Unfulfilled Promise From A Metamask Transaction

I'm having a problem with my JS code pausing on the let result line. Metamask prompts me to approve the transaction initiated in the line (which I do), but then doesn't proceed any further. As the ...
0
votes
0answers
26 views

Not able to call the solidity function through App.js? Anyone know how to call a solidity function?

I'm trying to call a Solidity function from App.js, but I'm unsuccessful even after a number of tries. Its a very simple function betOnTeam(). Inside this function I just want to check condition and ...
0
votes
0answers
17 views

Error => invalid address, on passing arguments to function

so I created a function but then I needed to make it dynamic so that I will be able to call the same function body just bypassing the arguments on click of a button I am fetching the values from HTML ...
0
votes
1answer
30 views

How to call such a function? (pass argument)

For example, here is the code What will the best code practice, either to repeat the code inside two different functions or what can I do? OraclizeContract.deployed().then(function(instance) { ...
0
votes
0answers
27 views

Signing Ropsten transactions with

I am trying to sign transactions using the Web3 HDWalletProvider package and an infura API. I am using the following code: const Web3 = require('web3'); const Web3HDWalletProvider = require("web3-...
0
votes
1answer
38 views

Function stopped working? No check is being done now on transfer function

I created a function to deposit and transfer ether and it was working great until i tried to deploy again and now the transfer function is not working anymore No errors are being thrown, the transfer ...
0
votes
2answers
53 views

Cannot transfer ether from smart contract to another address

I am using truffle and when we type truffle develop it provides us with 10 address ** So, the problem I am facing is I have created 2 functions one to deposit ether and the other one to transfer the ...
0
votes
0answers
53 views

Cant call solidity function from app.js?

Solidity function Using web3 0.20 version and Cant call solidity BETONTEAM function pragma solidity ^0.4.22; import "installed_contracts/strings.sol"; import "installed_contracts/oraclize-api/...
0
votes
1answer
25 views

Can we take input of an address and pass it on the function to send ether using truffle and web3?

Actually i am trying to create a betting application so when i get the result that Home team has won Before this i will be taking both address as input (betting do two address whoever wins gets the ...
1
vote
2answers
30 views

How to read data returned by a function? [duplicate]

Counter.sol: pragma solidity >=0.5.0 <0.7.0; contract Counter { uint public _counter = 0; function GenNextID() public returns (uint) { return _counter++; } } I use ...
0
votes
0answers
52 views

How to call solidity function from javascript file? Keep getting error deploying through truffle and webpack

Error -> TypeError: fetch.amount is not a function [WDS] Disconnected! Please explain or provide code on how to call solidity function Trying to call from ready() function console.log(contract.abi)...
0
votes
1answer
317 views

Getting error -> unexpected token. You may need an appropriate loader to handle this file type

root@kali:~/Documents/oraclize-test# npm run dev truffle-oraclize-api@0.0.2 dev /root/Documents/oraclize-test webpack-dev-server ERROR in ./app/javascripts/app.js Module parse failed: /root/...
3
votes
4answers
361 views

How essential is a knowledge of Javascript to learning solidity/ethereum?

I am new to the ethereum space, and though I can code in C and C++, I keep noticing in the docs that there are references to Javascript and node.js and how similar it is to solidity as well as ...
0
votes
1answer
40 views

web3 error - web3.eth.Contract is not a constructor

i try to get the contract balance and im using this var Web3 = require('web3') var web3 = new Web3('ropsten.infura.io/v3/123456789') var abi = abi is here ; var contractAddress = '0x31111.....'; var ...
1
vote
1answer
25 views

How can you work around Web3 1.0s bug to check for transaction confirmation?

The following includes a null Tx id: web3.eth.getTransaction('0x2fc36f9c6593bc1232b3466832c6ee38b5b2b3b4a54be3f6c68fb06e8d82e452', function(error, result){ if (!error) { console.log(result....
0
votes
1answer
92 views

Metamask (Chrome extension) web3.js console: ETH transaction issue (synchronous methods) + web3.version

I am playing around with Metamask and the web3.js API using the Google Chrome console. However, I have two issues: 1) I am trying to send a simple transaction using Ganache GUI (localhost 7545) and I ...
1
vote
2answers
75 views

Ganache Processing becomes very slow (with Automining Option) after consecutive thousands transactions

I am trying to deploy thousands of contracts on Ganache GUI. At first, it process all transactions very fast (deploy contracts and transactions for calling setters functions) . After some transactions,...
0
votes
0answers
30 views

Collection of erc20 tokens from multiple addresses

I have main address: const fromAddress There is also an array of addresses and their keys: foreth / keys I need to send all tokens from the addresses of the foreth array to the main address ...
1
vote
1answer
165 views

How Can You Find the Ethereum Provider on Web3 Browsers Other Than MetaMask?

MetaMask provides the following way currently to find a provider for their upcoming 2020 breaking change: // Running on the page, in the browser // This API will go live in Q1 2020 // It will be the ...
1
vote
2answers
46 views

The method eth_sendTransaction does not exist/is not available, when using Ropsten Network

My following code previously works perfectly at Ganache, but when i switched it to Ropsten Network, it give captioned error. Here is Code: async function finalSettersFunctions(){ var myFunc; ...

1
2 3 4 5
13