My contracts were tested in both Browser Solidity and Mist Wallet and it works fine. I am trying to use testrpc and trying to depoy

Below is the javascript I am using it on truffle console

contribute - is a function which will accept address and it is of payable type. "0xe014b7528ae8b245b829dca3f9abceabc777b387" is the contract address

Please let me know what could be wrong here.

truffle(development)> hub.then(function(instance){
return instance.contribute("0xe014b7528ae8b245b829dca3f9abceabc777b387",{
}).then(function(result) {console.log(result)});
  • It's a little different between truffle 2 and 3. Which one are we talking about? Mar 5, 2017 at 15:40
  • I am developing using truffle 3
    – sun
    Mar 5, 2017 at 15:45

2 Answers 2


First, use the migrations script in ./migrations, usually 2_deploy_contracts.js.

Comment out the MetaCoin example and ...

artifacts ... path to your source file

Back to linux shell, root dir of your project.

$ truffle migrate


The foregoing just gets truffle situated to help you out. In particular, it knows the contract address and function abstractions.

$ truffle console
> var contract = ContractName.deployed();
> contract.contribute({value: 1}); 
> contract.balance

I'm hoping the simplified syntax helps you out. I imagine it should work okay because you're pausing between each step.

Use .then(function(result) {}) to start working with "thenable" responses in scripts that don't wait around for the user to type something.

  • I tried for sometime and now able to send funds. Have attached few screen shots and code. Thank you Rob !!
    – sun
    Mar 5, 2017 at 19:19
  • Great. Polly worth a bump if it helped. The results are BigNumbers, so more fun ahead. Try contract.balance.toString(10); Mar 5, 2017 at 19:28

I have added step by step instructions as suggested. I hope it would help someone

pragma solidity ^0.4.8;

import "./B.sol";

contract A {

   address[] public addElements;

   function A() payable {


   function create(string x,string y) returns (address a) {
       B obj = new B(x,y);
       return obj;

   function contribute(address x) payable returns (bool) {

    if(msg.value == 0) return false;

    address contributor = msg.sender;

    bool isFailure = B(x).donate.value(msg.value)(contributor);

    return isFailure;


   function getElements() returns (address[] ) {
       return addElements;


pragma solidity ^0.4.8;

contract B {

     struct details  {
        string name;
        string desc;

   details public param;

   function B(string a,string b) {
       param.name = a;
       param.desc = b;

   function donate(address x) payable returns (bool) {

    // TODO functionality to be added
    return true;


   function getInfo () constant returns (string name, string desc) {
        return (param.name,param.desc);


screen shot 1 screen shot 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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