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
17 views

Get contract's balance in js test

When getting contract's balance on Remix, it returns the correct answer. But when the same function is called with JS Test, it returns a lot of junk. I referred to How to get a contract's balance ...
0
votes
1answer
19 views

Web3 js proper way to call a Reading contract function

So i recently took over a project that had been abandoned for a while, which involves an ECR20 smart contract and the use of the web3 library to communicate with the smart contract. I've been trying ...
1
vote
1answer
23 views

keccak256 output is different on ruby vs javascript…?

Ruby ethereum libraries use: https://github.com/phusion/digest-sha3-ruby require 'digest/sha3' '0x' + Digest::SHA3.new(256).hexdigest('0x0') => "...
0
votes
0answers
19 views

How can I get the ABI from solc.compile? (^0.6.4)

In pragma solidity ^0.6.4; I wrote a contract and can get the byte code as follow: const solc = require("solc"); const path = require("path"); const fs = require("fs"); const inboxPath = path....
0
votes
1answer
13 views

How to listen to Metamask Ethereum events

I am trying to listen to the 'chainChanged' event for Metamask, but the event never fires. When running the following snippet, the I get a console.log of the chainId once, but the chainChanged event ...
0
votes
2answers
8 views

Transaction won't be mined / Failed signing of transaction

I'm trying to send a transaction that writes somesthing on ethereum(kovan) but it seems my transaction is not mined and probably not even send to the network? All my view requests to ethereum work, so ...
1
vote
0answers
16 views

Why ethers.js sign function not working?

I am using the ethers.js library, and am trying to code a transaction. Here is a snippet where I connect a wallet to a provider, connect to a contract I want to call a function in, and try to call the ...
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
29 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
18 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
22 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
31 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
25 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
35 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
27 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
34 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
60 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
32 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
59 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
31 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
385 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
366 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 ...

1
2 3 4 5
13