1

I have the following outputs -

> eth.getStorageAt(con.address,0)
"0x00000000000000f07044ba718e8eb25850be0e534f9522018784be60043a984d"
> eth.getStorageAt(con.address,1)   
"0x00000000000000000000000046fb9a22689c4a4bfb494baeafbb8b2993725305"
> eth.getStorageAt(con.address,2)
"0x0000000000000000000000000000000000000000000000000000000000000000"
> con.buyer()
"0xf07044ba718e8eb25850be0e534f9522018784be"
> eth.coinbase
"0x46fb9a22689c4a4bfb494baeafbb8b2993725305"
> eth.defaultAccount
"0xf07044ba718e8eb25850be0e534f9522018784be"
>

Here is the contract -

pragma solidity ^0.4.18;

contract CollegeAdmin {
uint8 public studentAge=18;
uint16 public studentIncome=15000;
uint8 public studentScore=4;
uint8 public studentAttendance=96;
address public buyer;
address public owner;
event changedAge(uint age);

function CollegeAdmin() public {
owner = msg.sender;
}
function setAge(uint8 age) public {
buyer=msg.sender;
studentAge = age;
changedAge(age);
}

}

I expected the default account to be used and hence owner = defaultAccount which then is shown in slot 1 of the storage. But slot 1 has eth.coinbase. But when I run setAge, I find that the buyer it then set to eth.defaultAccount.

It seems to be truffle deploys under eth.coinbase and then the contract runs under eth.defaultAccount.

I tried changing truffle.js -

module.exports = {
   networks: {
   development: {
   host: "localhost",
   port: 8545,
   network_id: "*",
 gas: 4712388,
 from: "0xf07044ba718e8eb25850be0e534f9522018784be"
 }
}
};

This then gives a network error.

Using network 'development'.

Running migration: 1_initial_migration.js
  Replacing Migrations...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful 
transactions manually.

This is I imagine related to eth.coinbase but geth does not let me change that.

Has anyone any ideas?

1

If you want to specify the creator of the contract directly in the deployment scripts

var MyContract = artifacts.require("MyContract");

module.exports = function(deployer) {
  deployer.deploy(MyContract, { from: "0xACCOUNT" });
}
| improve this answer | |

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.