web3

How to return json data to a react state?

旧城冷巷雨未停 提交于 2019-12-17 21:22:14
问题 I have a react component that makes a .post to an express server (my own server). The server uses web3 to sign a transaction on Ethereum . Once the transaction is included in a block, a json object is returned to the server. It looks like this: { blockHash: '0xcd08039bac40e2865886e8f707ce9b901978c339d3abb81516787b0357f53fbd', blockNumber: 4611028, ...other data... transactionHash: '0x12c65523743ed169c764553ed2e0fb2af1710bb20a41b390276ffc2d5923c6a9', transactionIndex: 1 } I need to store the

How to await a json return value (the return takes at least 30 seconds) before logging it? javascript/react/express

隐身守侯 提交于 2019-12-14 04:06:09
问题 This is a follow up to these threads: How to set state of a react component with a specific item from a returned json object? How to return json data to a react state? I am using web3 to sign a transaction on Ethereum , which then sends a json object with transaction data. The json takes at least 30 seconds to return. I am trying to console.log() the data with the following code: axios.post( "http://compute.amazonaws.com:3000/users", { value: "value", fileName: "fileName", hash: "hash" } )

Installing python modules like “Web3” without pip/pip3?

笑着哭i 提交于 2019-12-13 03:33:01
问题 I have an armv7 embedded device. There is a yocto linux running on this device. There is no pip installed in it so i cannot install web3 using .. pip install web3 How can i install web3 or any python module without using pip? I have tried searching the recipe of web3.py but couldnt find any. Can i cross compile the web3 module? how to do that? how can build from source work for this module? what about the other dependencies required for it? I am not a full time linux or python deveopler so

invoke a smart contract function from java application without need to listen to events

China☆狼群 提交于 2019-12-13 02:13:03
问题 As I understood that we have to use TransactionReceipt if we want to extract the events.. TransactionReceipt transactionReceipt = contract.someMethod( <param1>, ...).send(); but what about for example if I have a function called "register" and need many accounts to register their self by invoking the function register. how I can define accounts ( many credentials ) if the TransactionReceipt doesn't have parameters for ( from which account, gas limit, ..etc). One more thing that I invoked the

Unit test error with mocha and chai Timeout of 2000ms exceeded. For async tests and hooks

南楼画角 提交于 2019-12-11 16:05:08
问题 My code: const assert = require('assert'); const ganache = require('ganache-cli'); const Web3 = require('web3'); const web3 = new Web3(ganache.provider()); const { interface,bytecode} = require('../compile'); let accounts; let inbox; beforeEach( async() => { accounts = await web3.eth.getAccounts(); inbox = await new web3.eth.Contract(JSON.parse(interface)) .deploy({data: bytecode,arguments:['Hi There !'] }) .send({from: accounts[0], gas:'1000000'}); }); describe("inbox", () => { it('deploys a

How to integrate smart contract via web3 and infura provider

◇◆丶佛笑我妖孽 提交于 2019-12-11 07:36:33
问题 I have created a project with infura provider const web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/v3/07630919731949aa87a45b96c98a834d')) And I try to call a smart-contract's method { to: addressTo, from: addressFrom, data: { name: 'addWhitelisted', inputs: [{ name: 'account', address: '0x57e755461FF79176fC8f14B085A8CBb4AE1fC2f6' }] } } Then I need to sign a transaction and call web3.eth.sendSignedTransaction ? But when i sign i get an error. Pls help. What I'm

What is the difference between web3.eth.accounts.create and web3.eth.personal.newAccount

荒凉一梦 提交于 2019-12-11 02:38:50
问题 As I understand when using web3.eth.accounts.create(), it doesn't add the account to chain (I'm using ganache-cli for testing), but web3.eth.personal.newAccount() does. Is it the main purpose or is it a bug? Is there other differences? web3.js version: 1.0.0-beta.34 回答1: Both versions create a new account on the blockchain. The difference is how you interact with the node and having access to the private key. If you have a local node, you can use web3.eth.accounts.create which will create the

How to connect web3 to ethereum network using flutter?

丶灬走出姿态 提交于 2019-12-10 23:36:28
问题 i am getting error while connecting with ethereum node this line ==> print(client.getBlockNumber()); returns error E/flutter (22015): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: SocketException: Failed host lookup: 'localhost:8545' (OS Error: No address associated with hostname, errno = 7) import 'package:flutter/material.dart'; import 'package:http/http.dart'; import 'package:web3dart/web3dart.dart'; import 'dart:async'; const String url = 'https://mainnet.infura.io'; /

Can I transfer tokens from an ERC20 contract using PHP?

落爺英雄遲暮 提交于 2019-12-08 10:56:01
问题 I'm developing a website using Web3 with Metamask, users can purchase tokens by sending ETH to an address. What I want to have done is that after the ETH is received it sends the tokens to the users ETH address automatically with backend code. The actual contract code Sending is not working unless the account is on Metamask Any tips on how I can get it to send the tokens through the backend by specifying the private key of an address with tokens? Thanks for your help. 回答1: Yes, you can, I

Repeating transactions hangs - web3js, local geth

為{幸葍}努か 提交于 2019-12-07 08:25:44
问题 I have an issue with transactions on my local ethereum network - at some point, transaction hangs & spends a lot of ETH from my account. Here's a sample code: async function send(toAccount, weiVal) { let account = await w3.getDefAccount(); for (let i = 0; i < 100; i++) { let res = await web3.eth.sendTransaction({ from: account, to: toAccount, value: weiVal }); await helper.timeout(2000); } } send('0x5648...', 100000000000000); It hangs at sendTransaction call (promise is never resolved) on