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.

0
votes
1answer
9 views

Get “i” in asynchrounous request

I have a view-request which returns amount X and will then fire a function X times through a for-loop. It works everything but due to the asynchronous request, I do not get the correct i-value that ...
0
votes
1answer
24 views

Accessing one smart contract contained in another smart contract from javascript

I'm cross-posting this from Stack Overflow, since there seems to be more activity here. I am trying to develop a dApp with Truffle and want to test my smart contract. The contract contains a second ...
0
votes
0answers
24 views

How do I call my smart contract functions through web3 js?

So I am very new to Blockchain development so sorry in advance! I have deployed a very basic Smart Contract to the Ropsten testnet. I am developing a front-end and from here, I want to withdraw ether/...
1
vote
1answer
18 views

Is it possible for a contract to auto-execute a function every hour? [duplicate]

I have a contract with a manual function that checks the balance of the contract and if it's zero it changes certain values in mapping. How to make this happen automatically every hour?
0
votes
0answers
17 views

Error use account to deploy the smartcontract: Send

let accounts; let inbox; beforeEach(async () => { //get a list of all accounts accounts = await web3.eth.getAccounts(); //use one of those accounts to deploy the contract inbox = ...
1
vote
3answers
53 views

Do you need to use/learn Solidity to make smart contracts

I'm working on an API that sends multiple transactions out from one wallet. I realized I cannot do it without creating a smart contract the way Ethereum is structured which is actually quite a great ...
0
votes
1answer
26 views

Dealing with events in ethers.js

I'm trying to get a better understanding of arbitrary bytes parameters, so I wrote a one-function smart contract that accepts a bytes argument, decodes it, and returns the response. I am having ...
1
vote
1answer
12 views

How do I send multiple transactions from one wallet in Nodejs?

Hi I've been reading around and I came across Web3.js It's not apparent to me how I can send Ether from one wallet to multiple recipients other than in a batch-style request (which inevitably takes a ...
0
votes
1answer
19 views

How to prompt and create Smart Contract using React

Weird question, so I have created a smart contract, verified that it works, even deployed it using Web3, Metamask and HTML/Javascript. I understand that worked. Now I am trying to integrate it into ...
0
votes
0answers
24 views

Store data on ethereum block chain using react js

I'm trying to store data on ethereum blockchain by doing this import storemetadata from "./storemetadata"; where i have the smart contract ABI in storemetadata I now add name like so storemetadata....
0
votes
0answers
15 views

Error when calling Ethereum Contract

I am using a JS library which calls Solidity functions and I been getting the following error: 0x0c444aa3066f98d5f7ee576401e7729cb1113fe288d38711a78e48836313e88c App.js:112 TypeError: createLog is ...
0
votes
0answers
26 views

Smart contract migration through Proxy delegate pattern in solidity 0.5

I am trying to do smart contract migration in solidity 0.5 using the proxy delegate pattern. When I write the integration test in javascript how should i make a delegate call using the proxy contract ...
0
votes
1answer
47 views

Web3: web3.utils is undefined

I am kinda new to Ethereum and Web3 so I am trying to implement the Ethereum: Building Blockchain Decentralized Apps (DApps) tutorial. I have already installed web3 and web3-utils. npm view web3 ...
3
votes
2answers
85 views

Truffle Test Issue With `address payable` and Compiler Version

I am trying to run truffle test on an old contract which was written using pragma solidity 0.4.24;. While I am able to deploy the contracts using truffle migrate, I get the following error when ...
0
votes
1answer
41 views

How to sign a transaction using nodejs crypto?

I have a js client, web API Js client send some data in JSON format, API prepare a transaction to be send to a smart contract, than it returns transaction raw to client to be signed locally, and ...
0
votes
1answer
23 views

Truffle Test async problem [closed]

When I "truffle test" and the below runs, I get 1,3 as the output. How do I make everything happen in order, I want to force it to wait until dai is defined. const DAI = artifacts.require("DSToken"); ...
0
votes
1answer
27 views

Truffle - how to share variables and functions between test files? [closed]

I have files in Test directory, each one performs different test but all of them contain at least exactly the same functions "register" and "vote", also few arrays like votings = [], groups = [] and ...
0
votes
0answers
96 views

How to access the return value of function of ethereum contract using web3 in javascript?

I have written a basic hello world! smart contract and deployed using testrpc and truffle. I have a function in the contract that returns a value and i am using this function and the value it returns ...
0
votes
0answers
12 views

Is it possible to write to a file from a truffle console?

I am running some tests on my smart contracts and I need to gather a bunch of data to process in a spreadsheet. Is it possible to write to a file from the console?
0
votes
0answers
56 views

ipfs.files.add(Buffer) function causing TypeError: Cannot read property 'add' of undefined

I am trying to upload an image to ipfs using ipfs.files.add() function but it is causing me this error Uncaught TypeError: Cannot read property 'add' of undefined at App.onSubmit (App.js:70) at ...
0
votes
1answer
27 views

Making assertions (assert.equal) on two return values in Truffle

Appreciate any help I can get. I am trying to make an assertion on returned values from a smart contract, and I cannot figure out how to get it to work for a Truffle test. I cannot show all my code in ...
0
votes
1answer
248 views

web3.min.js is missing in ./node_modules/web3/dist

I am following the below tutorial to create implement blockchain using web3. https://medium.com/coinmonks/interacting-with-ethereum-smart-contracts-through-web3-js-e0efad17977 When I am using npm ...
0
votes
1answer
104 views

BigNumber Error: new BigNumber() not a base 16 number:

I'm new to Ethereum and javascript so hope someone can help me with this as none of the other answers on BigNumber help me understand why this won't work for me. I've tried converting the number to a ...
0
votes
1answer
173 views

How to deploy a smart contract using Infura and web3js@1.x.x on NodeJS?

I have an application written in NodeJS that each time it starts has to deploy a smart contract. Once the contract is deployed this application will interact with it making some transactions and ...
1
vote
0answers
26 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,...
0
votes
0answers
39 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
2answers
41 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 ...
3
votes
2answers
197 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
30 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. ...
2
votes
1answer
37 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
179 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
205 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
73 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
57 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
32 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
43 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
107 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
28 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
44 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
265 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
63 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
24 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
41 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
86 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
48 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
54 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
71 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
425 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 ...