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
-1
votes
1answer
517 views

in web3 for wei take value at decimal? [closed]

Thanks in Advance. In web3.eth.util.fromwei, take value at what decimal?
2
votes
0answers
292 views

Using Truffle with Node JS (MongoDB)

I am trying to use truffle along with a MongoDB database which means that I need multiple ports. For local testing, I have been starting up my RPC, switching the port that the app is listening, and ...
0
votes
2answers
3k views

Using truffle-contract.js to load contract

I am having an extremely easy contract called Friend.sol: pragma solidity ^0.4.17; contract Friend { string name; uint age; function setFriend(string _name, uint _age) public { ...
0
votes
1answer
36 views

Error deploying new contract in Javascript using Meteor and TemplateVar

I am trying to create a new contract on button click using Meteor and TemplateVar. The relevant code is: Template.Borrower.events({ 'click button'(event, instance) { // Create new Borrower ...
0
votes
1answer
276 views

Automating Listing Addresses and Balances Using PHP

I want to incorporate a javascript in php that list all the accounts and shows balances for those. This is my script for that: <script language="javascript"> function checkAllBalances() { var ...
1
vote
5answers
4k views

Web3 - Cannot get accounts

I am trying to understand web3 better and tried out the following snipped: <script type="text/javascript"> if (typeof web3 !== 'undefined') { web3Provider = web3.currentProvider; ...
0
votes
3answers
1k views

Web3js does not connect to TestRPC in localhost

I am simply trying to run web3js in a node console and connect it to a testrpc running in localhost. I run my testrpc like so: > ganache-cli Ganache CLI v6.0.3 (ganache-core: 2.0.2) Available ...
1
vote
1answer
909 views

How do I call a function in javascript to call a solidity function using meteor and TemplateVar

I have created a very simple front end to display the borrower name. I deployed the contract Borrower on Rinkeby. I can run the application if I access the variable borrowerName using the following ....
0
votes
2answers
547 views

Web3js - Cannot read property deployed()

My smart contract was parsed via truffle compile to the following json file: { "contractName": "CryptoSportsToken", "abi": [ { "constant": true, "inputs": [], "name": "...
0
votes
1answer
239 views

Using a Linux Socket to Connect to the JavaScript Console

I'm trying to programmatically connect to a JavaScript console (just like you get with geth attach) using the geth.ipc file that gets created in the chaindata folder. On Linux, it's a socket file, so ...
1
vote
1answer
1k views

Storing IPFS hash in solidity

I'm storing IPFS hash in solidity using this guide https://www.reddit.com/r/ethdev/comments/6lbmhy/a_practical_guide_to_cheap_ipfs_hash_storage_in/ const cid = "...
2
votes
1answer
783 views

How does MetaMask save our mnemonic phrase? Is it safe enough?

How does MetaMask save our mnemonic phrase? Is it saved in browser local storage? Does it encrypt our mnemonic phrase?
0
votes
1answer
95 views

Learning to develop dapps, but trouble testing it

I'm starting to learn the in and outs of dapp development. I followed a few tutorials -I can now read solidity!. I want to try modifying some existing dapps to get a sense of what's going on, in ...
0
votes
1answer
95 views

web3js metamask function undefined after updating

I added a new function exampleFunc in solidity the mycontract.json file gets updated with that function with public visibility but web3.eth.contract(abiArray).at(address); does not contains the newly ...
0
votes
1answer
323 views

Truffle test: error when passing more than one file as input

I have several test files, which I can successfully execute via truffle test (having started a ganache-cli process). For example: ganache-cli truffle test test/test1.js truffle test test/test2.js ...
0
votes
1answer
351 views

Looping Through and Running the Same Method on an Array of Contracts

I am trying to retrieve the price of four contracts all using the same ABI. I have made the array 'Contract' so I can loop through them and apply the same method of "Price": var Contract = []; ...
0
votes
1answer
254 views

Struct Array length is always 1

This is the contract im calling createP to push Post struct Post { uint256 amt; bool isActive; address owner; } Post[] public posts; function createP(uint256 ...
0
votes
2answers
418 views

How to call undefined method of a contract using truffle javascript?

I have a dispatching contract, that defines fallback function to send all "undefined" calls to implementation contract using delegatecall: contract Dispatcher{ address _implementation; function() ...
1
vote
1answer
897 views

Truffle exec failure

I'm trying to run an external script in truffle. Basically I deploy the contracts with 'migrate' then want to run this script to set the variables. I just can't seem to get it to call correctly with:...
1
vote
1answer
344 views

Sending signed transaction to create a contract

My goal is to send a signed transaction to create a smart contract, however, I am facing an issue I have not been able to solve for few days: When I send the transaction (on a private chain), there ...
1
vote
2answers
687 views

Get Token Balance without using nodejs

I am trying to get Token Balance using plain javascript, no nodejs or web3. With web3 and nodejs I can do: exports.getTokenConfirmedBalance = function(node, query, abi) { return new Promise((...
2
votes
2answers
3k views

Authenticating a user via MetaMask (like Cryptokitties)? [duplicate]

I'm trying to understand how a user could be authenticated (like a sign in) using MetaMask, similar to how Cryptokitties makes you sign up/login? From what I understand, we need to have the user sign ...
1
vote
1answer
3k views

How to get the block number?

var test = await web3.eth.getBlockNumber(); I copied this code from the docs but when I call it I get this error: TypeError: e is not a function Anyone know what might be causing this? I'm able ...
0
votes
1answer
231 views

Trying to initialize accounts as global variable before starting Node console

Basically, I am trying to run a script that initializes all the variables I'll need during my Node console session. The script looks like this: global.Web3 = require('web3'); global.web3 = new Web3(...
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
1answer
605 views

Track progress of ICO sale

for a client of mine i'm creating a ICO website. The basic html & css code is fully done, and I have implemented a progress bar from Bootstrap on the webpage. My client asked me if it's possible ...
2
votes
1answer
2k views

Passing/returning callback function result

I think I am running into a callback issue as returning the result is saying undefined (despite being shown correctly in the console log). web3.eth.getBlockNumber(function(error, result){ if(!...
1
vote
2answers
1k views

Invalid JSON RPC response when calling a function

I've made a web3js script in a wordpress website, but when executing the following code, I get an invalid JSON RPC response. var Web3 = require("web3"); var web3 = new Web3(); web3.setProvider(new ...
0
votes
0answers
165 views

Executing custom script through non-interactive is different from executing through console

I have a private ethereum blockchain with a script, filename.js. miner.stop(); debug.verbosity(4) loadScript("path to FileStorage.js"); var DataStorageContract = web3.eth.contract(JSON.parse(...
1
vote
2answers
190 views

Is there any JS library can create a new Ethereum address from a password as input parameter?

In geth console we can create a new address like this: personal.newAccount("my-password") I'm looking for a library which can create a new account with my password without any Ethereum node.
1
vote
2answers
784 views

Should an API call be in the Solidity backend or the Javascript frontend?

I am fairly new to blockchain development. I want to call a function in my contract when a condition in the API is true. Should I make this API call in my contract, or in my frontend?
0
votes
3answers
307 views

Cannot get value from calling constant function with web3js and Metamask

I have an extremely basic contract deployed on Ropsten: pragma solidity ^0.4.16; contract hypergrowth { uint256 public someNumber = 5; function hypergrowth() public {} function changeNumber(...
1
vote
1answer
3k views

Web3 Error: no synchronous methods without callback parameter

I try to load the Metamask Web3 object into my react/redux frontend. On page load i encounter the following error: inpage.js:233 Uncaught Error: The MetaMask Web3 object does not support synchronous ...
0
votes
1answer
101 views

Truffle testing not reading contract

Here's my solidity: contract Oracle { mapping(uint => uint) oracle_values; modifier onlyOwner { require(msg.sender == owner); _; } function Oracle() public { owner = msg....
0
votes
1answer
186 views

Limitations of JavaScript api on client side?

I notice that the Ethereum Javascript API allows the development of client side web based apps. Are their limitations or security gotchas to be aware of when developing such an app? Parts of the API ...
1
vote
1answer
231 views

Hash a message in ethereum-js and check in Solidity

I'm trying to check an hashed message inside my Solidity smart contract. In JavaScript I hash the message as follows: util.sha3(Buffer.concat([ new Buffer(address1), new Buffer(bytes32), new ...
3
votes
2answers
854 views

Using Whisper with web3.js

I have been trying to figure out how to interact with whisper using web3. I have been able to successfully send (and receive) a message using geth console, but have been unable to do the same using ...
0
votes
1answer
262 views

Update dapp after contract transaction is mined

I made a web app that interacts with a smart contract, using truffle unbox webpack. My contract has a variable called sum and 2 functions: one called answer that increments the sum variable after it ...
2
votes
2answers
4k views

Is it possible to upload a file to IPFS using HTML's <input type=“file”> tag?

I'm trying to upload a file to IPFS and display the returning hash address on a browser using JavaScript and HTML. But I don't know how to handle the JavaScript API. My HTML code: <p id="text">...
0
votes
4answers
2k views

How do I implement buffer/readable stream in order to add a file to IPFS?

I'm trying to upload a file from my directory to IPFS. Below is what they require from API: const files = [ { path: '/tmp/myfile.txt', content: (Buffer or Readable stream) } ] ipfs....
0
votes
1answer
402 views

How to use smart contract setters from JS Console?

I'm having accessing my smart contracts' setters from console using a simple HTML / JS website. I'm able to access public variables and getters, but when trying to use my setters from console it ...
0
votes
1answer
70 views

Output of log.memory.slice in Geth debug_traceTransaction

Has anyone else used the JavaScript-based tracer that Geth provides, as part of its debug_traceTransaction method? I want to look at segments of memory during a transaction's execution (specifically, ...
2
votes
1answer
404 views

Error Installing web3js for Ethereum / Unable to connect to github.com

I'm using npm to install web3js: npm install web3 It eventually fails. Here is the output I get... npm WARN deprecated tar.gz@1.0.7: â ï¸ WARNING â ï¸ tar.gz module has been deprecated and your ...
2
votes
1answer
405 views

Understanding Truffle Migration

I'm building my dApp by modifying the pet-shop example, however, I got stuck at the migration step. 1_initial_migration.js runs successfully but 2_deploy_contracts.js gives me the following error ...
0
votes
1answer
438 views

Accessing Web3 in trufflebox's react-auth-box

Hi I am using trufflebox boilerplate react-auth-box. Created a new component called Foo where I am trying to access the web3 object that has been mapped from Store to this.props. However the console....
1
vote
2answers
38 views

Error in simple example code?

I'm playing around with truffle and I have this simple program here that I can't seem to get to work... contract MyContract { struct Test { bool testBool; } mapping (address => Test[]) ...
0
votes
1answer
456 views

Can't call functions from contract using web3.js

So I have a Dapp and want to call a function from a contract deployed on Rinkeby. I use Metamask to interact with the blockchain. When I use the functions in the console, they work, but when I want ...
2
votes
2answers
1k views

Best practice for multiple dependent requests in Web3.js

Looking to get some advice on a pretty common scenario using Web3.js Let's say you want to calculate the number of tokens for a specific ERC20 token contract that are present at an Ethereum Address. ...
1
vote
1answer
726 views

Passing data to smart contract via constructor

Is it possible to pass data into the constructor to be used for the smart contract? Essentially I want to let a user on the front end enter data that will be used to generate a token. contract ...
3
votes
1answer
5k views

How to pass argument/parameter to a payable function of a contract that has been already deployed, via web3 / javascript / truffle?

I'm wondering how to pass argument to a payable function of a contract that has already been deployed, via web3 / javascript / truffle. For instance, I see the following piece of code at: http://...

1
7 8
9
10 11
13