Hot answers tagged

16

1) INFURA (https://infura.io/) maintains those remote nodes. 2) You can trust those nodes for two reasons: Uptime and Relay of signed transactions (as opposed of keeping your private key in our servers). We strive to keep an uptime of 100% (which is our latest record). Transaction-wise, it is you, from your local machine the one that signs the transaction ...


13

I've replaced const web3 = new Web3(new Web3.providers.HttpProvider("http://rpc.ethapi.org:8545")); with: const web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/TOKEN")); and everything works. This https://ropsten.infura.io/TOKEN was given to me after registration on infura.io


12

Infura currently doesn't support WebSockets (required for events using Web3 v1, otherwise you get the error "The current provider doesn't support subscriptions" when using infura as HttpProvider), so what you have to do is run a local geth node that connects and syncs to the network. Here we enable the websocket flag and allow any origin to connect to the ...


12

You can either run a local node and specify your chain using --chain ropsten when starting geth/parity and connect to localhost once sync is completed or you can connect to infura.io: var web3 = new Web3(new Web3.providers.HttpProvider( 'https://ropsten.infura.io/v3/[infura_project_id]' ));


10

If you're using Truffle with Infura directly (which it sounds like you are, although it's unclear why you mention MetaMask), you need to be aware that Infura is running on a server farm. If you submit a transaction, the node that receives it first may not be the same node that handles the next transaction, or that handles the eth_getTransactionCount call ...


9

I have been using Infura with web3 1.0 in mainnet. Here is my code, hope it helps var Web3 = require('web3') var request = require('request'); var contract = require('truffle-contract') var zastrin_pay_artifacts = require('./build/contracts/ZastrinPay.json') var ws_provider = 'wss://mainnet.infura.io/ws' var web3 = new Web3(new Web3.providers....


9

more concretely metamask is connected to those infura's nodes : const MAINET_RPC_URL = 'https://mainnet.infura.io/metamask' const ROPSTEN_RPC_URL = 'https://ropsten.infura.io/metamask' const KOVAN_RPC_URL = 'https://kovan.infura.io/metamask' const RINKEBY_RPC_URL = 'https://rinkeby.infura.io/metamask' global.METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' module....


9

To run Mist using INFURA, you need to start it from the command line If you are using OSX, this is the command you want /Applications/Mist.app/Contents/MacOS/Mist --rpc https://ropsten.infura.io To use the main network, replace with https://mainnet.infura.io


9

This line ... nonce: window.web3.utils.toHex(window.web3.eth.getTransactionCount(fromAccount)), ... relies on a reliable transaction count from Infura. The problem is it's not as reliable (or even close) as you need it to be. This method will produce unreliable, inconsistent results as you have observed. Some background will help explain what is going on ...


7

This looks mostly correct, but there are a couple optional tx parameters that might make the difference: // EIP 155 chainId - mainnet: 1, ropsten: 3 chainId: 3, gasPrice: "0x9184e72a000", // 10000000000000 Also, the nonce may need to be converted to hexadecimal. The getTransactionCount method returns a javascript number, so you might need to convert ...


6

This my current implementation: getCurrentProvider() { if (!window.web3) return 'unknown'; if (window.web3.currentProvider.isMetaMask) return 'metamask'; if (window.web3.currentProvider.isTrust) return 'trust'; if (window.web3.currentProvider.isGoWallet) return 'goWallet'; if (window.web3.currentProvider....


6

As of v4.2.1, deploying a contract with a local key is a lot more straightforward. From the question's example code, here is a new approach: w3 = Web3(HTTPProvider("https://ropsten.infura.io/v3/YOUR_PROJECT_ID")) contract_ = w3.eth.contract( abi=contract_interface['abi'], bytecode=contract_interface['bin']) acct = w3.eth.account....


6

How did you get the bytecode? Does it have the '0x' at the beginning? Can you try adding the '0x' when submitting the transaction? .deploy({ data: '0x' + bytecode, arguments: ['Hi there!'] }) If you put '0x' in front of the bytecode it will assume the rest is in hexadecimal and left it alone. If there's no '0x' it will convert the whole string to ...


5

Here's a example of setting an infura provider using truffle-hdwallet-provider with a custom wallet: const HDWalletProvider = require('truffle-hdwallet-provider') const fs = require('fs') const mnemonic = process.env.MNEMONIC module.exports = { networks: { development: { host: 'localhost', port: 8545, gas: 4500000, gasPrice: ...


5

You can find an open issue in the Infura Git We're working on finding a solution to this which can provide the functionality createFilter/getLogs was providing in a way which is scalable and secure. This feature is "Stateful Transaction Support" and is tracked in this issue #10


5

INFURA nodes are public and receive a lot of traffic, and that is the reason that some JSON-RPC methods need to be disallowed. However, we're working on a solution that will make all methods available. A while ago we modified our architecture, so load balancers are not the issue. I'll check with the Truffle team about their use of filters and update this ...


5

Can you try printing out the raw serialized transaction and sending it to ropsten directly with CURL? https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendrawtransaction Do you get a txid back?


5

Here's what I am using: AWS Instance Setup New EC2 instance Ubuntu Server 16.04 LTS (HVM), SSD Volume Type - ami-10547475 t2.large: 2 vCPUs, 8GB RAM 250 GB (currently about 60gb is being used) nginx reverse proxy server: for ssl/https access (for my site which is https) tmux for persistence set up parity as a daemon process I am using parity instead of ...


5

Infura doesn't support filters. Per https://api.infura.io/v1/jsonrpc/ropsten/methods (from the documentation, these are the supported methods: { "get": [ "web3_clientVersion", "net_version", "net_listening", "net_peerCount", "eth_protocolVersion", "eth_syncing", "eth_mining", "eth_hashrate", "eth_gasPrice", "...


5

Got a reply from an Infura member. At the moment if you pin objects on their nodes they won't be removed. Unpinned objects are garbage collected when the data store needs to reclaim space. File size is not explicitly limited but you might encounter gateway timeout for very large files.


5

Apparently there's a nuance with the nonce... my error was I was setting the nonce to web3.eth.getTransactionCount() + 1, which left a gap between prior transaction nonce and next transaction nonce (nonces are 0 indexed, transactions are indexed from 1, that's the root of the error). It so appears that you are not allowed to increment the nonce by 2 and ...


5

was fixed on web3@1.0.0-beta.36 https://github.com/ethereum/web3.js/issues/1559#issuecomment-412348642


4

Also, you may want to try out Metamask, which is a Chrome plugin for connecting to Ethereum, managing your accounts, etc. (Metamask uses INFURA as a backend.) It's a faster UX since you don't have to download (and possibly sync) Mist. https://metamask.io/


4

Go here and generate a 12 word mnemonic, for "Coin" select ETH. Save the mnemonic (the 12 words), and, lower down the page, the first address (derivation path ending with 0) and private key somewhere safe. Transfer some ETH from your account to the one that corresponds to the mnemonic you just generated. You can import it into MetaMask with the private key ...


4

What you should do in this case is use the web3-provider-engine. An example code snippet functioning with a custom private key and Infura API URL (Or even TestRPC) would be the following: //Provider Engine sub-modules const ProviderEngine = require('web3-provider-engine') const CacheSubprovider = require('web3-provider-engine/subproviders/cache.js') const ...


4

I don't want to get a "golden shovel" reward or something but that question doesn't seem to be very old. I managed to successfully implement automatic reconnect thus I wanted to share the code: First I created a separate function getProvider: function getProvider() { const { WebsocketProvider } = Web3.providers; const provider = new WebsocketProvider(...


4

This is working #!/usr/bin/env node const Web3 = require('web3'); const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://mainnet.infura.io/ws')); const subscription = web3.eth.subscribe('newBlockHeaders', (error, blockHeader) => { if (error) return console.error(error); console.log('Successfully subscribed!', blockHeader); }).on('data', (...


4

One approach I've used in the past is to just instantiate two Web3s. E.g.: const web3 = new Web3(web3.currentProvider); // MetaMask const web3EventReader = new Web3("wss://rinkeby.infura.io/ws"); Then use web3 for your typical MetaMask stuff and web3EventReader to listen to events. (Side note: I changed /_ws to /ws, because I thought that's the proper URL....


3

I am looking for a better way myself, at least for metamask I found that you can do that: window.web3.currentProvider.isMetaMask


3

I had the same error. It was solved after I installed the old version of the npm libralies. I don't think this is the ideal solution. $ npm install ethereumjs-wallet bip39 web3-provider-engine@8.6.1 web3@0.18.4 zeppelin-solidity --save


Only top voted, non community-wiki answers of a minimum length are eligible