Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'sendRawTransaction, gasPrice,fromWei,toHex' does not exist on type 'Eth' or Web3 in web3 1.0.0-beta.26 #1197

Closed
helxsz opened this issue Nov 25, 2017 · 2 comments

Comments

@helxsz
Copy link

helxsz commented Nov 25, 2017

I am using angular4 to setup web3 (version 1.0.0-beta.26)

Property 'sendRawTransaction' does not exist on type 'Eth'.

import {Injectable} from '@angular/core';
import Web3 from 'web3';
import {default as contract} from 'truffle-contract';
import {Subject} from 'rxjs/Rx';

import {Tx} from 'ethereumjs-tx';

@Injectable()
export class Web3Service {
  private web3: Web3;
  public bootstrapWeb3() {
    if (typeof window.web3 !== 'undefined') {
      this.web3 = new Web3(window.web3.currentProvider);
    } else {

      Web3.providers.HttpProvider.prototype.sendAsync = Web3.providers.HttpProvider.prototype.send;
      this.web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
    }

  getTransaction(txHash){
      this.web3.eth.getTransaction(txHash, function(err, tx) {
            if(err || !tx) {
              console.error("TxWeb3 error :" + err)
            } else {
              var ttx = tx;
              console.log('getTransaction2',tx);
              //ttx.value = etherUnits.toEther( new BigNumber(tx.value), "wei");
            }
      }); 
  }


  sendRaw(rawTx,key) {
    var privateKey = new Buffer(key, 'hex');
    var transaction = new Tx(rawTx);
    transaction.sign(privateKey);
    var serializedTx = transaction.serialize().toString('hex');
    this.web3.eth.sendRawTransaction('0x' + serializedTx, function(err, result) {
        if(err) {
            console.log(err);
        } else {
            console.log(result);
        }
    });
  }
 }

In compiling the project, I got an error,

Property 'sendRawTransaction' does not exist on type 'Eth'
I can't understand why sendRawTransation fails but getTransaction works.

update

I found more function doesn't exist, like

Property 'gasPrice' does not exist on type 'Eth'
Property 'fromWei' does not exist on type 'Web3'.
Property 'toHex' does not exist on type 'Web3'
Property 'isConnected' does not exist on type 'Web3'.

```any ideas
@DalderupMaurice
Copy link

Same issue here!
(Commenting to stay updated)

@frozeman
Copy link
Contributor

frozeman commented Nov 27, 2017

It’s. Eth.sendSignedTransaction

There are differences to the old documentation, please refer to the new documentation http://web3js.readthedocs.io/en/1.0/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants