I'm new to web3.js and ethereum, and i'm trying to play with it coupled with meteor and angular 1.5.

I defined a component that creates a simple contract but i'm stuck after calling TestContract.at(address); - the error i get is "Error: provider not set" but just some lines before i send a transaction and HttpProvider is correctly recognized.

My simple component is:

import angular from 'angular';
import angularMeteor from 'angular-meteor';

import templateUrl from './mine-contract.ng.html';

class MineContract {
  constructor() {
    this.contractInstance = null;
    this.mining = false;

  mine() {
    this.mining = true;
    var transactionObject = {
      data: TestContract.bytecode,
      gasPrice: web3.eth.gasPrice,
      gas: 5000000,
      from: web3.eth.accounts[0]

    var _this = this;

    web3.eth.estimateGas(transactionObject, function(err, result){
      if(err) {
        console.log('err', err);
        _this.error = 'Something went wrong, the error is: ' + err;
        _this.mining = false;

        transactionObject.gas = result * 10;

      console.log('trans', transactionObject);
      web3.eth.sendTransaction(transactionObject, function(err, result){
        if(err) {
          console.log('err', err);
          _this.error = 'Something went wrong, the error is: ' + err;

        if(result) {
          _this.contractInstance = TestContract.at(result);
          console.log('contractInstance', _this.contractInstance);



const name = 'mineContract';

export default angular.module(name, [angularMeteor])
.component(name, {
  controllerAs: name,
  controller: MineContract

In my javascript console when i log console.log('contractInstance', _this.contractInstance); i get:

contractInstance Contract {_eth: Eth, transactionHash: null, address: "0x0ed4a0e14bb7b1a9173271a16c12690237663eff333b2ba26e9f6dbed4695b62", abi: Array[2]}

But after that it starts throwing exception web3.js:5996 Error: Provider not set or invalid(…) - i presume trying to get the transactionHash

Line that throw the error is:

RequestManager.prototype.send = function (data) {
    if (!this.provider) {
        return null;

But I can't understand what i'm doing wrong.

Can anybody helps me?

  • Have you set the provider by using web3.setProvider(....); @bre – Abhiram mishra Jun 30 '16 at 17:45
  • @The Neo Noir Developer yes in client/startup/connection.js i have Meteor.startup(function(){ if(!web3.currentProvider) { web3.setProvider(new web3.providers.HttpProvider("")); } // Setup EthAccounts EthAccounts.init(); }); and i'm using a test net, i can send and receive ethers – bre Jun 30 '16 at 18:02
  • 1
    Okay, check if you can access this in your browser. and also verify is your node (geth) running in rpc mode at 8000 port number @bre – Abhiram mishra Jun 30 '16 at 18:04
  • @The Neo Noir Developer - thank you for your help Neo, yes i can - with another component i can send and receive ethers from different accounts in the testnet – bre Jun 30 '16 at 18:08
  • having your geth is connected to network ( testnet) you would be able to do ether transfers,not necessarily it is an HttpProvider. Is your geth running is in --rpc mode and the address is set and the port number ;8000 ? Can you access the address in your browser ? Check what is the current provider by invoking web3.currentProvider in the browser console. check if the Meteor.startup() executes fine setting the provider. – Abhiram mishra Jun 30 '16 at 18:25

Your Answer

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

Browse other questions tagged or ask your own question.