[Ethereum] Truffle invalid address

testrpctruffletruffle-configtruffle-contractweb3js

With Truffle 3.0 when I call one of my contract's function, in console I have this error:

Uncaught (in promise) Error: invalid address

I found this workaround, and in my code I try this with no success.

this.web3Provided.eth.defaultAccount=this.web3Provided.eth.coinbase;

In truffle doc they sat I can set a from address in my config, but also this not work. from: '0x8c384d9f226ea92c99f7aa83340714a6f82a3161'

I also try with this after I have imported all truffle.config file:

TruffleConfig.networks[NODE_ENV].from = this.web3Provided.eth.coinbase;

Please help me.

Best Answer

Thank's to Truffle Gitter channel I figured out. I have to call defaults function on my truffle-contract's abstraction.

MyContract.defaults({from: …}) 

https://github.com/trufflesuite/truffle/tree/develop/packages/truffle-contract

buildContracts() {
    let contracts = {};
    let meta;

    this.props.contracts.forEach( _contract => {
      let {contract_name = ''} = _contract;
      meta = contract(_contract);
      meta.setProvider(this.web3Provided.currentProvider);
      meta.defaults({from: this.web3Provided.eth.coinbase});
      contracts[contract_name] = meta;
    });
    return contracts;
  }