Questions tagged [javascript]

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

180 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
2answers
194 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
152 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
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
31 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
248 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
82 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, ...
1
vote
1answer
84 views

Transferring an ERC-20 using web3js 1.0.0

I have been trying to follow the web3js documentation, but it mentions things that are not native to Javascript like "Buffer" so I found a library called ethereumjs-tx to let me use that. My HTML ...
1
vote
3answers
499 views

How to transfer token to an address?

Im using truffle and openzeppelin for issuing my ERC20 token. I already can add and buying the token, but still cannot transfer the token to another. when i console.log the contract, it show me: and ...
1
vote
0answers
418 views

Sending a transaction via web3.js is not working

I'm trying to send some ether and here is my code: function sendEth(fromAddress, secret, toAddress, amount) { let params = { to: toAddress, from: fromAddress, value: web3.utils.toWei(...
1
vote
0answers
148 views

Best way to process withdrawals for ETH?

New to ETH. Designing a web-wallet type of service. Currently generating new deposit address keypairs via web3.eth.personal.newAccount(). Iterating each block via web3.eth.getBlock(), and scanning the ...
1
vote
0answers
115 views

Javascript wallet with ERC20 support

I'm looking for a javascript wallet for Ethereum (like ethers.js for example) with support for listing the ERC20 tokens that the wallet is holding and also being able to send them to other wallet ...
1
vote
0answers
127 views

Toshi browser vs. Google Chrome browser to interact with Dapp?

Toshi is a browser to interact with Dapps such that after uploading our Dapp (including solidity smart contract, Javascript and HTML code) on a server, we can search our Dapp using its URL (ex: www....
1
vote
0answers
186 views

(browserify) Error : Cannot find module 'web3/lib/solidity/coder.js'

When I use command browserify viz.js -o main.js to build this project, I receive following error message : C:\Users\KX5710\Downloads\GUI_solarchain\solarchain-dashboard-master>browserify viz.js -o ...
1
vote
1answer
89 views

How to convert hashed result into readable format?

I'm trying to convert a hashed block number "30054a" into readable format but I'm getting logs something like this: 0J For another hashed value: Y����#�(�J�d��F,ĦJ/ I'm using the following code on ...
1
vote
0answers
184 views

cannot get return variable(s) in javascript when using require in solidity

I have a function in solidity that returns a few bytes32 variables. I cannot for the life of me access those variables. Can someone please help? function getData() public returns (bytes32, bytes32, ...
1
vote
0answers
1k views

How to access multiple return values from solidity function in web3.js

I have written a solidity contract deployed on Ropsten network. I am using lite-server, NodeJS to develop a front-end. I have figured out how to use events and I can access a getter with one return ...
1
vote
1answer
237 views

Truffle test case to unit test withdrawal pattern

How can I test the withdraw() function in a truffle javascript test case for the below contract? The problem is, If I use the msg.sender from the same contract, the before and after balance will be ...
1
vote
1answer
286 views

Watch pending transactions with ethjs.js

I am trying to use ethjs.js to listen to pending transactions, but nothing really worked. Does anyone have a working example fetching pending transactions with ethjs.js? I have tried the following: ...
1
vote
0answers
754 views

How to decode input data from a contract transaction without ABI?

I've found some libraries which decode input from transaction, but all of them require ABI of contract. Can I decode input data if I know only txHash, contract address and input data? How etherscan ...
1
vote
2answers
386 views

zeppelin-solidity Crowdsale. Access to token using javascript

I'm trying to use javascript to access the token variables and functions provided in the MintToken.sol file in openzeppelin. I used "truffle init webpack" to create the metacoin example provided by ...
1
vote
0answers
182 views

Is there some way to save an array (write file) through geth to a text file?

I'm looking to save or extract an array inside a file.js file in geth console to a text file. I have shearched this subject but i could find nothing related to this. Is this possible? I tried: /....
1
vote
2answers
729 views

How can geth access contract variables through the console?

I'm using the Mist wallet just to display the contents of the contract. Bellow, you can see the code to access the contract function (submitUnits) and the result of the LoadScript when I run in the ...
1
vote
0answers
36 views

how does the js command run in source codes?

I just want to be clear how dose the js command run. I trace the code when I type admin.peers in geth console. Then I found that it runs in jsre.go: // Evaluate executes code and pretty prints the ...
1
vote
0answers
179 views

I can't addpeer in a private chain, why?

There are 2 nodes(10.0.50.90, 10.0.50.91), and they can ping each other well. There are geth in every node and their genesis json file is same.Then I run geth in evey node. In 90's geth console: > ...
1
vote
0answers
103 views

Ether.li transfer problem despite correct password

AFter entering correct passwort when trying to transfer ETH on ether.li (via browser), I always get an error message "Type error: Object doesn't support property or method 'assign'"... Does anyone ...
1
vote
0answers
266 views

geth js commands to handle my Wallet contract

I have created a Wallet contract using the Mist. Now I am trying to handle it using geth console javascript commands. By handling I mean sending ether to an account. Can someone help me with the js ...
1
vote
1answer
534 views

Call a function from an account

Knowing that account0 = 0x2ac971cfceb478a3db5a43598e098839007cec34 account1 = 0x55990a8c443a0eb296cff4bece4c54350185b019 I started testrpc. After that, I called a function buyItem(moneyPaid,{from:...
0
votes
0answers
5 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 ...
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
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 ...
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?
0
votes
1answer
20 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 ...
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
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
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 ...
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
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
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
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 ...
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
374 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/...
0
votes
1answer
42 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 ...
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 ...