1

i am working on the web3 1.0.0 -beta.36

my code is simple, to connect to infura service and fetch a transaction.

let rpcUrl = "https://mainnet.infura.io/ocCdekUYwOyLn7h7OlJM";
      var web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl));
      web3.eth.getTransaction("0xaf7bfec2f84b35a58e93ebdf688ba079721b2ac064d7adff520100352206472d")
          .then(txObj => {
            console.log( txObj); // logs "string"
        });

[sm]:1 ERROR Error: CONNECTION ERROR: Couldn't connect to node https://mainnet.infura.io/ocCdekUYwOyLn7h7OlJM.
    at Object.InvalidConnection (errors.js:31)
    at HttpProvider.send (httpprovider.js:94)

Why i could not connect the infura service?

4

Looks good to me:

https://jsfiddle.net/m3afvn0c/

<script src="https://cdn.rawgit.com/ethereum/web3.js/1.0/dist/web3.min.js"></script>
<script type="text/javascript">
  let rpcUrl = "https://mainnet.infura.io/ocCdekUYwOyLn7h7OlJM";
  var web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl));

  web3.eth.getTransaction("0xaf7bfec2f84b35a58e93ebdf688ba079721b2ac064d7adff520100352206472d")
    .then(txObj => {
    console.log( txObj); // logs "string"
  });
</script>

Output in console:

blockHash: "0x5e937a40e6213f2e27ef193e454c2dac67d487591df6bbf4fd7b4c6fbb1d1042"
​
blockNumber: 6375283
​
from: "0x5Fb9A2b7AE59A85565809044a418CC35eab13c25"
​
gas: 67670
​
gasPrice: "16000000000"
​
hash: "0xaf7bfec2f84b35a58e93ebdf688ba079721b2ac064d7adff520100352206472d"
​
input: "0x23b872dd000000000000000000000000237b64806c7883e778e9b74edde05f903524d6900000000000000000000000005fb9a2b7ae59a85565809044a418cc35eab13c25000000000000000000000000000000000000000000000094cae0664ceabbe800"
​
nonce: 2565
​
r: "0x6dad8ac29469c6ffb0daf5aed64e4351155cbcdd08e180c48404ffed85cd5b03"
​
s: "0x440566bf839a5edf1d506b4829b6cdbefdf1d9f12706b4c78a2de25e01cba022"
​
to: "0x8dd5fbCe2F6a956C3022bA3663759011Dd51e73E"
​
transactionIndex: 12
​
v: "0x25"
​
value: "0"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.