Stack Exchange Network

Stack Exchange network consists of 175 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.

1
vote
0answers
15 views

Unable to retrieve ethereum address from the signed data

I used the web3.eth.accounts.recover method to retrieve the ethereum address but I am getting an error. Here is the code: let v = '0x' + signed_nonce.slice(130,134); let r = signed_nonce.slice(0,...
-4
votes
0answers
10 views

Big Number Error : Bignumber is not a base 16 number [on hold]

http://disq.us/p/1zvfcta Please solve and fix the error occured on the system.
0
votes
0answers
7 views

Debugging a reverted transaction

I have two wallets: Wallet1: 0x8882528C7104e146E0500203C353C09922575385 Wallet2: 0xddCf0FeC78b5a20B9138F5DDb1357E3B60026a67 Each of them has more than 1 Ropsten ETH. Using web3js and Infura ...
0
votes
1answer
11 views

Props object value not flowing to next page [on hold]

I am unable to figure out why the props.query.address is returning "undefined". I am using next.js for routing. Please have a look at below screenshot, Please note the highlighted route, When i ...
0
votes
2answers
27 views

Uncaught Error: Invalid number of arguments to Solidity function

function TriggerContract() { var account = getAccounts(); var test = web3.eth.defaultAccount; console.log(account); var q = document.getElementById("Quantity").value; var ...
2
votes
2answers
38 views

How to use bignumbers in truffle tests?

I am testing a smartcontract with Truffle V5. All works well if I do not use all decimals. If I set 18 decimals all explodes. The test code is this (from truffle docs): const MetaCoin = artifacts....
1
vote
0answers
10 views

Javascript library to use zkSnark circuit

I would like to generate the proofs for zkSnarks on client side and therefore would need a library in javascript that helps to read a circuit and generate proofs. I found one combination here which ...
0
votes
0answers
21 views

cannot retrieve token price

i am trying to code a decentralized application and what i am trying to do right now is to get the token price of 1000000000000000 and display it. but when i try to get token price i keep getting 0. ...
1
vote
0answers
21 views

Event Watching Web3 v1 in Truffle test

I want to test off chain data input in truffle testing. So basically I kick off a test and then need to wait for another program to do something. In the old web3, this worked great: function ...
0
votes
2answers
52 views

How can I select a single account in Ganache? [duplicate]

Ganache (v1.2.3) provides a list of 10 accounts. They can be easily selected by selecting web3.eth.getAccounts();. However web3.eth.accounts[0] returns undefined as shown below. Not sure how to ...
0
votes
2answers
33 views

How to get events emitted by a transaction with web3.js

I'm writing a user interface in Javascript and I'm using the web3.js library. I have the transaction hash of a confirmed transaction. I would like to get an array of all events emitted by that ...
0
votes
1answer
44 views

How to get array elements in JavaScript from contract call with JSON-RPC returning an array?

I have a function in my Solidity contract whose prototype is: function checkLastCustomerInvoices() public view returns (bytes32 [] memory) When I call it from the Truffle console it returns an array ...
1
vote
1answer
32 views

Mocha and web3.js without await [closed]

Awaiting the resolution of calls to a node works for me, like this example: describe('some contract', async function () { ... it('data should be written correctly', async function () { ...
0
votes
1answer
27 views

Check if contract is destructed

Once a contract is no longer valid (eg after calling selfdestruct on it), one can still call functions on it although the contract won't behave as expected. In javascript, how can one check if the ...
0
votes
1answer
14 views

Javascript Read Message Value Received

In my smart contract, I have a function that sends ether to the caller using the msg.sender.send() function. I need to check that the value being returned by the function is correct (i.e. the amount ...
0
votes
3answers
36 views

ABIs and Solidity programming

This is a practical question. I am developing an application in Solidity with Remix. One thing that takes a lot of time is that when I make changes in the code, I then have to compile it in Remix and ...
1
vote
0answers
34 views

web3 - promise doesn't work as expected

I'm trying to write a code that reads variable, adds 1, sends update call, waits until the transaction is done and then reads the variable again. Console shows that the transaction is complete, but ...
0
votes
1answer
18 views

ERC777 granularity rounding error

I'm making a token with ERC777 standard. I've got my decimals at 18, and I want whole tokens, so I set granularity to 10^18. when I try to mint 20 tokens, I get granularity error. So I made a ...
0
votes
0answers
27 views

Truffle-contract cannot find module 'debug'

I'm trying to connect my smart contracts to a frontend app using web3 and the truffle-contract node package. In my client-side javascript file, I am requiring the package as follows: import contract ...
0
votes
1answer
60 views

TypeError: Cannot read property 'toNumber' of undefined

Cannot read property 'toNumber' of undefined? Error message 1) Contract: DappTokenSale ends token sale: TypeError: Cannot read property 'toNumber' of undefined at test/...
0
votes
1answer
40 views

Solidity Vs JavaScript?

I'm currently in the process of writing a game however a question has popped up in my head. A while back I started writing my game in Solidity (i.e the characters, names, stats etc.) and I had ...
0
votes
0answers
19 views

How to find out if a transaction was successful in javascript?

I want to do a transaction from my website to a private blockchain and inform the user after the transaction is done. This is my code so far: const web3 = new Web3(new Web3.providers.HttpProvider("...
0
votes
1answer
15 views

Stream ethereum (ERC20) transactions (node.js)

I would like to get discord message every time when address receive ERC20 token. Is there any way to stream Ethereum transactions? I tried https://github.com/AlexanderC/ethereum-transaction-stream ...
0
votes
1answer
61 views

Data availability in Ethereum/Hyperledger-fabric (Blockchain)

I have a use-case like there is an admin who creates application and invites several user to use that application. Now, i need to audit trail over the activities done by the user. Users no need to ...
2
votes
1answer
36 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.
1
vote
1answer
39 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
41 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
175 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
31 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); }); ...
2
votes
1answer
76 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
18 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
31 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 =...
1
vote
0answers
44 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 ...
1
vote
2answers
157 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
24 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": ...
1
vote
1answer
16 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
42 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
49 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
48 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
113 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
58 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
108 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
158 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
235 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
177 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
59 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
43 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
54 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
33 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
17 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. ...