Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [javascript]

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

0
votes
0answers
17 views

How to get most expensive/cheap values in array?

I am working on a DEX solidity smart contract. I have an array orders[] which uses the struct struct Order { uint tokenAddress; uint pricePerToken; uint tokenAmount ... When the user ...
-1
votes
0answers
23 views

Calling smart contract function that have parameters using web3 in javascript

Here is the problem I am having: //this is just a smart contract i just picked up from etherscan var c = web3.eth.contract([{"constant":true,"inputs": [{"name":"user","type":"address"},{"name":"token"...
0
votes
0answers
23 views

Election dApp. UI and backend

here is a code that i downloaded from GitHub and tried to learn, folowing this tutorial. It's simple dApp for election. It uses these dependencies: MetaMask Truffle Ganache Shortly ...
2
votes
1answer
10 views

How to get amount of ERC20 tokens sent in tx from tx hash? (Web3.js)

I have tx hash and I would like to see how much ERC20 tokens was sent in this transaction. How can I do this with web3.js? Thank you.
0
votes
1answer
21 views

Truffle Assert with Truffle Beta

I just updated to Solidity 5 and Truffle Beta and am testing my contracts in JavaScript. I am trying to test my constructor events and want to use as per truffle-assertions documentation : truffle-...
1
vote
1answer
20 views

Ethers js adding provider

I have an app I am working on implementing ethers.js. There are two methods I am using to create a wallet: new ethers.Wallet(privateKey, provider); and new ethers.Wallet.createRandom(); With creating ...
1
vote
3answers
41 views

contract methods undefined

I am quite new with javascript web3 so don't be judge too hard. I am using web3 version 1.0.0 beta. I am taking the web3 reference this way: if (typeof web3 !== 'undefined') { // If a web3 ...
0
votes
1answer
25 views

Get lastest input transaction of the account

I am trying to get the recent IN transaction of the account while i try web3.eth.getTransactionCount("0xF092966e7bcc2b5646e0F0c20A715584DB37cd4B").then(function(trans){ console.log(trans); }); ...
0
votes
0answers
30 views

Javascript returns a “is not a contract address”, but the contract is deployed in Truffle

I am getting the following error within my web browser while running Truffle locally. I tried to re-compile and then I check with a fresh install. Any ideas on how I can fix this? Error: Error: ...
2
votes
1answer
59 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 ["",...
0
votes
1answer
12 views

Truffle Exec Return Events

I have set up a JavaScript file that takes in my contract and executes the various functions and then returns the correct events. The file runs through 'truffle exec'. I am using the following line ...
2
votes
0answers
25 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 =...
0
votes
0answers
24 views

connecting smart contract to user interface

I am working on a smart contract and can connect to the smart contract via user interface(.html page) using web3 . I have a bunch of theses pages in the same folder and they are working except for ...
1
vote
0answers
40 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 ...
0
votes
0answers
12 views

How to create Uint8Array from mysql data

var aaa = '<?php echo $row_key["address"]; ?>'; var bbb ='<?php echo $row_key["pwderivedkey"]; ?>'; var ccc = global_keystore.exportPrivateKey(aaa, bbb); console.log('ccc:', ccc); ...
0
votes
0answers
16 views

How to upload keystore to connect lightwallet function and get privatekey

A: <form id="signup" method="POST" action="totalupload.html" enctype="multipart/form-data"> <input type="file" id="myfile" name="myfile" accept=".json"> password:<input ...
1
vote
2answers
53 views

Truffle Tests Events via JavaScript

I am testing my contract via the chai and truffle-assertions libraries from a JavaScript file and am testing if events return the correct values. I have an event called Message. In my function, the ...
3
votes
0answers
21 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": ...
0
votes
0answers
13 views

How to recover keys from mnemonic phrases

I am developing an Ethereum HD wallet, and I want to use the JS implementation of BIP39 from here. I'm trying to understand how a recovery of keys should work. I am thinking of a following process. ...
1
vote
1answer
15 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 ...
0
votes
1answer
38 views

How to sign on ethereum a pdf like on this video? [closed]

How to sign on ethereum a pdf like on this video? I'm asking specifically about what happens at 00:40 where you have a user uploading the file and then it get stored and cryptographic signature is ...
1
vote
1answer
26 views

How to generate address from xpub in JS?

How to generate address from xpub in JS? Should i use BIP39 or 44? If yes, how exactly?
1
vote
0answers
28 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
1answer
31 views

Truffle test, logs do not include an emitted event

I am calling a contract function which emits an event in a transaction. This transaction should include the event and is typically visible via: const receipt = await contractInstance.someFunction() ...
1
vote
2answers
41 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
54 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 = ..., ...
0
votes
0answers
34 views

Truffle-contract error on deployed contract

Playing around with the gnosis multisig, using truffle-contract to interact with already deployed MultiSigWallet using truffle migrate. Contents of the file I am trying to run: var contract = ...
0
votes
1answer
79 views

How to use infura API with web3 js? [duplicate]

How to use infura API with web3 js? Where should I put secret key?
0
votes
1answer
42 views

ethers.js (node.js) call solidity function that is payable

I understand that you can send ethereum to a smart contract, although when you do this with sendTransaction it doesn't seem that you specify a function on the smart contract when you do this. I don't ...
1
vote
1answer
33 views

get same output as solidity SHA256 in JS

Is there a js function/library which gives same output as sha256 in solidity? I am saving a hash in a mapping and can access it via cli (truffle console) and see what the hash is but I would like to ...
0
votes
2answers
21 views

Javascirpt 18 decimal number for parameter?

I have created an 18 decimal crypto token in ethereum. When executing smart contract method from javascript for uint256 input parameter, how can I specify the number with 18 zeros? Because javascript ...
0
votes
1answer
24 views

web3js (v1.0.0-beta36) unable to use - Cannot find module 'buffer'

I included dist/web3.js (1.0.0-beta36) in my html file as below <script type="text/javascript" src="./web3.js"></script> <script type="text/javascript"> var Web3 = require('web3'...
1
vote
1answer
29 views

Must token contract transfer all tokens to crowdsale contract before it can sell them?

I notice that on the standard tests for crowdsale contracts in Openzeppelin, they transfer the tokens from the Token contract to the Crowdsale Contract: context('once deployed', async function () { ...
1
vote
1answer
16 views

Dapp SDK - Hardcoded ABIs vs Dynamic ABIs

I am developing a Javascript SDK to allow for integration of external services with our Dapp. The SDK calls the smart contracts' methods and therefore needs to know contracts addresses and ABIs. ...
1
vote
0answers
39 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 ...
0
votes
0answers
27 views

failed to connect Localhost/Infura

I am trying to access a smart contract method through web3.js, but while a request, i am getting a following error in the console. web3.min.js:1 Failed to load https://rinkeby.infura.io/v3/...
1
vote
1answer
37 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 ...
0
votes
1answer
48 views

How do I check the Ethereum balance and unique transactions count of a Smart Contract over a period of time?

Basically I want to be able to track smart contracts balance and unique transactions over a period of time such as , last 24hours, last hour and so. What would be the best approach into doing this? ...
1
vote
0answers
22 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 ...
1
vote
2answers
45 views

Estimate Gas Price (not Gas) using Web3

Using Web3, we are able to estimate the amount of gas needed for a transaction let estimatedGas = web3.eth.estimateGas({ to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", data: "...
0
votes
1answer
57 views

How to use infura with web3 to talk to remote ropsten node?

I understand we need mnemonic as we did use it in deploying contract with truffle so as to be able to send ether from our ropsten account private keys. I could not find a way use the same in my server....
2
votes
0answers
59 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 ...
1
vote
1answer
23 views

How to use web3js to put it in json?

I have used web3js by using it in the form of node(npm). But I don't know how to extract some data generated from nodes. Does anyone know this web3js so the results can be changed to json form? ...
0
votes
0answers
22 views

Getting Addresses using a Path causes the error: Could not derive hardened child key

I am using ethereumjs-wallet npm package to generate a unique wallet address for each user. However instead of using the mnemonic/seed, a public extended key xpub will be used instead to keep the ...
0
votes
1answer
59 views

Calling a “view” function using web3js

--- HEAVILY EDITED --- Solidity contract: pragma solidity ^0.4.24; contract PatientRecords { struct Patient { string ID; string weight; string height; string diseasehistory; ...
1
vote
1answer
42 views

fromAccount and web3.js

This is my function in solidity function transferForm(address _from, address _to, uint256 _value) public returns (bool success) { } Now i am calling the same function in test file for testing my ...
0
votes
1answer
46 views

Too many decimal places error

So I am putting together a test for my contract and this is the it() statement: it('allows one account to enter', async () => { await lottery.methods.enter().send({ from: accounts[0], ...
0
votes
1answer
50 views

Need help in deploying a dapp on Ropsten without truffle

I am trying to deploy a Decentralized application on Ropsten without using truffle (trying to challenge myself), but for now I am stuck at few places, the deploy.js file which is supposed to deploy ...
0
votes
1answer
36 views

Create accounts on ethereum network using programmatically generated key pairs and addresses

Say I have a node application that has user registration feature. Now when a user registers, using node libraries like crypto I generate a cryptographic key pair(private and public). Then also ...
2
votes
2answers
118 views

'truffle compile': TypeError: Type uint256 is not implicitly convertible to expected type tuple(uint256,address)

Attempting to test this repo in Ubuntu 18.04: https://github.com/ETH-Pantheon/Aion Truffle v4.1.14 (core: 4.1.14) Solidity v0.4.24 (solc-js) Here is the main contract I've already deployed to my ...